I am not a programmer so I’m sure this is a no brainer. I am trying to disable a popup if WordPress users are not logged in. I am using CSS to disable the popup for a specific Woocommerce plugin. The CSS code works fine if I use it by itself. However, when I try to use it with the PHP function to check if users are logged in it does nothing. Any help would be greatly appreciated.
add_action('disable_popup','check_if_logged_in');
function check_if_logged_in()
{
if (! is_user_logged_in())
{
add_action( 'wp_head', function () { ?>
<style>
.ex-fdlist .exwf-order-method { display: none; }
</style>
<?php });
}
}
Advertisement
Answer
Probably you don’t have an action named disable_popup being called. Did you already try something like this?
add_action(
'wp_head',
function () {
if ( ! is_user_logged_in() ) {
?>
<style>
.ex-fdlist .exwf-order-method { display: none; }
</style>
<?php
}
}
);