Conditionally opening Popup Maker popup in wordpress with jQuery Conditionally opening Popup Maker popup in wordpress with jQuery wordpress wordpress

Conditionally opening Popup Maker popup in wordpress with jQuery


Your solution is correct but currently Popup Maker defers js loading so your code runs before the .popmake('open') function has been loaded and the popups initialized.

We are going to be addressing that soon, but try adding a short timeout before opening it:

jQuery(document).ready(function($) {    setTimeout(function() {        $('#popmake-2503').popmake('open');    }, 2000);});

or better yet hook into the pumInit event like so. That way it opens as soon as the popup is actually ready. This is also safe to load in the head as it uses .on event binding

jQuery(document).on('pumInit', '#popmake-2503', function () {    PUM.open(2503); // Newer method than $('#popmake-2503').popmake('open'); and uses internal selector caching.});

And lastly if you want a reusable solution you can create custom conditions that can be used in our popup condition editor. You only need one condition to do both true & false checking. The following doc includes multiple complete examples you can use:

PS I'm the lead developer for PM so this is the defacto best answer ;)


You try to grab popup with id selector #popmake-2503, but i your question saw, that it has class popmake-2503. So try to change this line:

jQuery(document).ready(function($) {   alert ('running');   $('.popmake-2503').popmake('open'); //class selector});


You can avoid using jQuery. This allows to disable the plugin when some condition is not true.

add_action('wp', 'disablePopup');function disablePopup () {    if (/*Some condition is not true*/) return remove_action( 'wp_enqueue_scripts', 'popmake_load_site_scripts');}