I’m trying to hide the following content that’s inside of content-product.php to guest users (make it invisible to users that are not registered):
<?php if( get_field('___unit_price') ): ?>
<p>Unit Price: $<?php the_field('___unit_price'); ?></p>
For the life of me I can’t get it to hide. Any help would be appreciated.
You need more conditional logic.
only checks if the
get_field()
function returns a value, but you also want to check if the user is logged in. Conveniently, WordPress has a function calledis_user_logged_in()
that checks exactly that.