I have a membership site and need prices hidden until the user is logged in. How can I adjust this so prices are hidden only for users who are NOT logged in?
.imagemapper-wrapper .my_product_price { display:none !important; }
Currently prices are hidden from everyone.
4
Answers
So I ended up merging two answers together. display: inherit wasn't working so I tried block !important instead and it worked like a charm. Thank you all for your advice and suggestions. I am now able to hide both the price and add to cart buttons when a user is NOT logged and show them when they are! I was beyond excited when I finally got this to work. Thank you all!
One way you can do this is with the
wp_head
hook. In the hook you can echo the style if a user is logged in withis_user_logged_in()
. See below:Another option is to use a custom css classname:
Then is your css use the new classname:
If you want to use CSS instead of removing the pricing unless the user is logged in, use the
wp_head
filter. Put this in yourfunctions.php
file:This uses
is_user_logged_in()
function to test if the user is logged in. If the user is not logged in, print this style in your header.CSS only option: