Hello,
You can use the following code to set a cookie whenever someone subscribes using the “Top Bar” plugin.
/**
* Set cookie when Top Bar is used to subscribe
*/
add_action( 'mctb_subscribed', function() {
$expires = time() + ( 60 * 60 * 24 * 30 ); // 30 days
setcookie( 'mctb_hide_bar', '1', $expires, '/' );
});
/**
* Do not load Top Bar when cookie exists
*/
add_filter( 'mctb_show_bar', function( $show ) {
return $show && empty( $_COOKIE['mctb_hide_bar'] );
});
You will need to add the above code to the “functions.php” file located inside your active theme folder.
Once the cookie is set, if they visit the page again, the top bar will stay hidden for 30 days.