Wordpress has built in .logged-in class name for that. You need to wrap your text in a custom class that is invisible by default and visible for the logged in users.
In your product:
<span class="secretmessageforusers">Bla bla bla</span>
In your CSS:
.secretmessageforusers {display:none;}
.logged-in .secretmessageforusers {display:block;}
Wow !!!!!
Fantastic help! Many thanks!!!
I am surprised that it is something so simple, I have asked a lot about this issue and all the solutions were complicated or you had to install a plugin.
How can I place the text below the price?
Try this snippet:
add_action( 'woocommerce_single_product_summary', 'my_custom_text', 25 );
function my_custom_text() {
print '<span class="secretmessageforusers">Bla bla bla</span>'.PHP_EOL;
}
I am unable to test it with your theme.
You can use this plugin for snippets:
https://ww.wp.xz.cn/plugins/my-custom-functions/
Thanks for the reply!
The code did not work! Do I have to change some of the code you gave me to make it work?
Regarding the plugin, I read that it is to add code but I have not seen that it allows me to move the code that I have already added thanks to @superkot
It is right?
I tested the code on my site and it worked. I was not able to test it with your theme because it is a commercial theme and I don’t have a copy. Its possible that your theme uses different hooks.
The code I gave you is php and it goes at:
Dashboard > Settings > PHP Inserter
Ensure the “On” button is green on that page.
@superkot gave you some custom css, and this goes at:
Dashboard > Appearance > Customise > Additional CSS
When you have it working, it will show the same text on every product page. Come back for how to have different text for different products.
Plugin Support
Hannah S.L.
(@fernashes)
Automattic Happiness Engineer
We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.
Hello everyone!
I am sorry for the delay in responding but I was doing tests and I have encountered a problem.
How can I make the text appear exclusively for a specific user role?
I’ve noticed that currently any user who logs in can see the text but what I want is that the text can only be seen by the “Partner” Users
It’s possible?