Auto-close pop-up and hide for a couple days

I'm trying to have the popup automatically close after 20 seconds, and prevent that from displaying to the user before 7 days if the popup is manually closed.

See image

Unfortunately if the auto-close option is activated, the cookies that makes the expire options possible are not set in the browser. Which causes the pop-up to display every time the page load.

Any possible workaround to have both features at the same time?

  • Predrag Dubajic

    Hi Momoka,

    Can you try downloading the attached file, unzip it and place it inside wp-content/plugins/hustle/assets/js/ folder, and overwrite the existing one.
    The message about two options will still be there but they should be working nevertheless.

    Also, please note that these are core plugin changes so after update is released you will need to apply modified file again, however, devs are discussing about including this as default behavior in future releases.

    Best regards,
    Predrag

  • Konstantinos Xenos

    Hi Momoka !

    You can achieve what you want by adding this code into your functions.php ( preferably in your child-theme ). This will emulate a users 'click'.

    Make sure to change the number in $('.module_id_1 in the code to correspond to your Slide-In ID. You can find the ID by editing the Slide-In and looking at your address bar ( see address bar attached screenshot ). As an example if you have &id=12 then you should make it .module_id_12.

    I'm also attaching a screenshot showing my testing settings. I only have the "No longer show this message across the site" enabled.

    Extra not: the } , 20000 ); part of the code is the 20s you want but in miliseconds. You can change that to anything you like. In example 3000 would be 3 seconds instead.

    add_action( 'wp_footer', function() {
    	?>
    	<script>
    	( function ( $ ) {
    		$( 'document' ).ready( function() {
    			setTimeout( function(){
    				$('.module_id_1 .hustle-modal-close .hustle-i_close').click();
    			}  , 20000 );
    		} );
    	} )( jQuery )
    	</script>
    	<?php
    } );

    Tell me if this helps!

    Regards,
    Konstantinos

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.