Is it possible to have two different protection message output?

Hi

Is it possible to have two different protection message output? So for this code:
[ms-protection-message]
Could there be a second one like this:
[ms-protection-message2]

I want different message output/text on same page.

  • Ash

    Hello Hamid

    You can create your own shortcode and add your custom protection message in there:

    function m2_pc_msg_func() {
    	return "Your custom message";
    }
    add_shortcode( 'ms-protection-message2', 'm2_pc_msg_func' );

    You can learn more in here: https://codex.wordpress.org/Function_Reference/add_shortcode

    You can use this code in your theme's functions.php if the theme is not changed. Otherwise mu-plugin is the best option. To create a mu-plugin, go to wp-content/mu-plugins folder. If there is no mu-plugins folder then, create one. Now, inside the mu-plugins folder create file with name anything.php (make sure file extension is .php). Now start with a <?php tag and then put the above code.

    Hope it helps! Please feel free to ask more questions if you have any.

    Have a nice day!

    Cheers,
    Ash

  • Hamid

    Hi Ash

    Thanks buddy. Yes your code does what it is suppose to, But it does not act like the normal `
    [ms-protection-message]`

    See attached screendumps.
    The message does not disapper again. When correct user level is logged in.

    I have your code above a GOLD member protected content, when the gold level user is logged in., this should not be seing.

    The other issue is, that when a free member is logged in, remember i have silver and gold content on same page, so when the free user is logged in, he can see above silver and gold same message. Which is the default protected message
    [ms-protection-message]

    Now with your code above the gold, i have two messages. I dont know how to remove the gold one as it is part of the overall gold member [ms-protect-content id="4055"][/ms-protect-content]


  • Hamid

    Hi

    The membership plugin seems to have this option it self, but i can´t seem to get it to work.

    See the first screen shot here. There is a general tab in the membership settings tab. In the protection messages there is the text i put in there.

    In the individual membership plan there is also a protection message(See screenshot)

    This one is for my gold member as you can see in the text.

    And the same goes for the silver membership it has it own protection message text also, but it is not these which are showen, it seems like the generel message from screenshot one overrides these..

    Please advice...

  • Sohag Ronjon Dey

    Hello Hamid,
    Thanks for your reply and hope you're having a beautiful day.

    From your last two messages it seems you want to have protected content for both two membership and also for individual membership in the same page. Please correct me if I am not getting your message. So if this is what you want you can do like the following.

    Suppose your gold membership id is 31 and your silver membership id is 43.

    So when you like to protect a content for both gold and silver you can wrap your content like the following

    [ms-protect-content id="31,43" msg="Sorry! this content is accessible only to silver and gold members. Upgrade your membership to access this."] orem ipsum dolor sit amet, consectetur adipiscing elit. Duis at diam nunc. Phasellus at fermentum nisi, id sollicitudin dui. Phasellus eget turpis varius, sollicitudin orci quis, hendrerit est. Interdum et malesuada fames ac ante ipsum primis in faucibus. [/ms-protect-content]

    and when you like to protect a content for only gold you can wrap that content like the following

    [ms-protect-content id="31" msg="Sorry! this content is accessible only to gold members. Upgrade your membership to access this."] placerat quis dictum sit amet, dignissim sit amet tortor. Proin non molestie elit, mattis tempus quam. Vestibulum consectetur orci pharetra elementum pulvinar. Aenean finibus fermentum magna, id eleifend justo iaculis vel. [/ms-protect-content]

    and when you like to protect a content for only silver you can wrap that content like the following

    [ms-protect-content id="43" msg="Sorry! this content is accessible only to silver members. Upgrade your membership to access this."] placerat quis dictum sit amet, dignissim sit amet tortor. Proin non molestie elit, mattis tempus quam. Vestibulum consectetur orci pharetra elementum pulvinar. Aenean finibus fermentum magna, id eleifend justo iaculis vel. [/ms-protect-content]

    The msg value is for demo. You can edit the value to your preferred text.

    Hope this helps. Please let us know if this does not work. We are always here to help.

    Cheers,
    Sohag.