Hi @qwik3r,
Just to confirm: You’d like to make sure that popup is seen at least once on the first of every month to all of your visitors?
But, you still want to provide a cookie for that popup so your visitors don’t repeatedly see it after they hit the close button?
If that’s right, you can write custom code to:
1) Check the date.
2) If the date matches the first of the month (date = 1), then clear the cookies for that popup.
3) If a visitor comes on the first of the month, sees the popup, and clicks the close button, respect the cookie that’s set until the first of the next month.
Here’s an example. Note that the date is set to today (11th) for testing purposes.
/**
* Add custom JavaScript scripts to the footer of your site theme.
*
* @since 1.0.0
*
* @return void
*/
function monthly_popup_cookie_purge() { ?>
<script type="text/javascript">
jQuery( document ).ready( function ($) {
const date = new Date();
// Clear cookies only on a specific date (day of the moth).
if ( date.getDate() === 11 ) { // Change this to the date you want.
// Don't clear cookies if you've already cleared them today.
if ( PUM.getCookie('pum-purged') ) return;
// Clear the cookies.
PUM.clearCookies( 673 ); // Change the popup ID to yours.
// Remember that you've cleared them today.
PUM.setCookie( 673, { name: "pum-purged", expires: "+1 day", path: "/" } ); // Change the popup ID to yours.
}
} ); // jQuery
</script>
<?php }
add_action( 'wp_footer', 'monthly_popup_cookie_purge', 500 );
/**
* Add to your child theme's functions.php file or use a code snippets plugin.
*/
Feel free to use and tweak it to your needs.
We hope that helps.
Let us know if we missed something or if you need anything else.
Have a great day ??
Mark