• Resolved ciberdom

    (@ciberdom)


    Hello!

    Someone knows if it is possible to add text in products that only users can see. I just need to add a couple of lines but each product will have a different text.

    Thanks in advance!!!

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • superkot

    (@superkot)

    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;}
    Thread Starter ciberdom

    (@ciberdom)

    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://www.ads-software.com/plugins/my-custom-functions/

    Thread Starter ciberdom

    (@ciberdom)

    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.

    Thread Starter ciberdom

    (@ciberdom)

    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?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Messages for Users’ is closed to new replies.