How To Hide Opt-ins In WordPress Using jQuery?

In this post I'll share how I managed to hide an Optin, that did not hide as expected even after changing the settings in the OptinMonster plugin.

I’ve been working on one of the WordPress projects, that uses OptinMonster a lot. If you’re new to OptinMonster, then checkout OptinMonster’s website to learn what it is and what you can do with it.

What Problem Did I face?

The client wanted to show Optins only for logged-out Users yet the Optins’ were popping up even for logged-in users. Normally, we can use Optin Monster’s output settings to hide Optins to logged-in users. But in my case, this did not happen and the Optins continued to pop up for all users.

How Did I Solve?

Having tried the display settings in the Optin Monster plugin, I found from their docs that I could use their Javascript events API to stop Optins from popping up. I plugged the following snippet only to logged-in Users using wp_enqueue_script function and Conditional tags.

This snippet will be handy if you happen to deal with Optins that are real monsters.

Leave a Reply

Your email address will not be published. Required fields are marked *