M2 - Dynamic Shortcode to show/reveal content on a page dependent on membership level

Hi,

I'd like to see a feature where I can surround certain content with a shortcode to only display that content dependent on a membership level. For example:

<!-- shortcode that only displays content for member levels 1, 2 and 3 -->
[M2 Show_For="L1, L2, L3"]
##YOURCONTENT##
[/M2 Show_For]

<!-- shortcode that only displays content for member levels 1 and 2 -->
[M2 Show_For="L1, L2"]
##YOURCONTENT##
[/M2 Show_For]

This will allow me to have a page that displays a list of training module buttons which will become visible when the next level of membership is activated and the relevant dripped content is available to the user.

Thanks,

Ash

  • Adam Czajczyk

    Hello Ash,

    I hope you're well today and thank you for your question!

    The Membership 2 Pro plugin already supports this. There's a number of shortcodes that you can use, including content protection shortcodes. Here's an example:

    [ms-protect-content id="5782"]
    This is my hidden content visible only for members of selected membership
    [/ms-protect-content]

    An ID value is an ID of the membership that you'd like your content make visible to.

    You'll finds ready to use shortcods for each of your existing memberships in your dashboard on "Membership 2 -> Memberships" page under the "Show" link (see screenshot).

    I hope that helps!

    Best regards,
    Adam

  • ash

    Hi Adam,

    Thanks for that information. How would I apply this single shortcode across multiple memberships? If I wanted to only show certain content with specific members could I just use a comma to apply multiple member protection? E.g:

    [ms-protect-content id="5782, 5882, 5982"]
    This is my hidden content visible only for members of selected membership
    [/ms-protect-content]

    Thanks!

    Ash

  • Adam Czajczyk

    Hey Ash!

    That's a yes :slight_smile: You can use multiple memberships IDs with the shortcode that way. In your example you're making the "This is my hidden content..." content available to all users that are members of memberships 5782, 5882 and 5982 at once.

    Additionally, you could use the shortcode to apply "reverse" protection. While an example I shared with you previously gives members of membership 5782 access to the content, this would instead hide the content from them:

    [ms-protected-content id="5782" access="no"]
    This is my content that I want to hide from members of membership ID 5782
    [/ms-protected-content]

    The solution above is particularly useful if there's many memberships and you would like them all to be able to view the content but hide some small part of it (e.g. a paragraph on a page) from selected members.

    I hope that helps!
    Best regards,
    Adam

  • ash

    Ok, great. I'm just curious how this works for dripped content? How to I enable certain items to appear when each dripped item becomes available? If I protect content with a membership ID that would probably display all instances of that membership, wouldn't it?

    I'd want to control the visibility of the dripped items so that when a user reaches a certain duration (every 3 months) the next item will appear.

    Thanks,

    Ash

  • Adam Czajczyk

    Hello Ash!

    The "dripped content" membership is quite specific one and it's supported only via "Membership 2 -> Protection Rules". You may of course use regular "protection shortcode" with it as described in my previous post here but in case of "dripped content" membership it will not respect "dripped" (time based) rules and will only show/hide content as with any other type of membership.

    In order to make full use of "dripped content" membership you will want to go to "Membership 2 -> Protection rules" page in your dashboard and then add that membership to selected content that you wish to protect. You'll be able to set date ranges for that content to specify when it should be made available.

    I'd want to control the visibility of the dripped items so that when a user reaches a certain duration (every 3 months) the next item will appear.

    You can do that via "Membership 2 -> Protection rules" as explained above.

    I hope that helps!

    Best regards,
    Adam

  • ash

    Ah, yes, then my previous feature request should have been more specific regarding a 'dripped' membership... apologies

    I'm aware of setting protection rules with a dripped membership which I have done but that doesn't address multiple items of content (images, paragraphs, videos) on a single page which need to appear when each drip is available.

    I essentially have 4 exercise modules dripped to the user but I want one single page to display all exercise modules and dependant on what stage of the "dripping" they will see the relevant content.

    Being able to control the dripped 'content' itself is important and not just protect an entire page or menu item, right?

    Anyway if this can't be done I'd really like to see this added as new feature soon.

    Thanks :slight_smile:

  • Adam Czajczyk

    Hello Ash!

    I got a word from a plugin developer and currently this is not supported by Membership 2 Pro plugin. In case of "dripped content" membership the only way to go is to use Protection Rules.

    I do agree however that this would make a great feature so I'm moving this thread to our "Features and Feedback" forum and hopefully more members of our community will support the idea so our developer will implement it in one of future releases.

    I'm thinking of a workaround though. You could post "content to be dripped" as separate posts and protect this posts with Protection Rules and then use this plugin:

    https://pl.wordpress.org/plugins/iframe/

    It let's you easily embed any URL into single WP post as an iframe. You could then embed those protected posts into a single post and as a result for that content that hasn't been "dripped" yet users would just see a protection message and for that that has already been open, the content would be shown.

    I hope that helps!

    Best regards,
    Adam

  • ash

    Hi,

    Is it possible to set url re-directs to certain pages based on the users dripped membership status?

    For example:

    I have four thumbnail links on a page each linking off to their respective training modules. If a user is halfway through their dripped membership they would be able to access module 1 & 2 but when clicking on modules 3 & 4 they would be re-directed to a holding page saying 'content coming soon'. This isn't as good as the shortcode idea because a user has to click on the link to find out that they don't have access yet but I just wondered if this could be achieved?

    I know you can set a 'Content protected page' but I'd like to add a specific message dependent on the dripped membership status.

    I have a few other feature requests relating to dripped content. Is there a direct way of adding these?

    Thanks,

    Ash

  • Adam Czajczyk

    Hello Ash!

    Is it possible to set url re-directs to certain pages based on the users dripped membership status?

    Currently, there's no such feature included in Membership 2 Pro plugin. However it would be possible with a bit of custom coding. Creating such a code would be a bit outside the scope of this support forum but if you feel like giving it a shot yourself let me just share some tips.

    The Membership 2 Pro plugin includes and API that can be used fetch/manage its data (including e.g. user's membership status) with your own code. API usage and functions are described right inside your dashboard on "Membership 2 -> Help -> API Docs" page.

    Here's an example (commented) of how to use Membership 2 API inside your theme's functions.php file:

    https://gist.github.com/bappi-d-great/991a90a4c4c936f00c6a

    Taking above as an example you should be able to build a code (using a bunch of functions described in API Docs) that would check if a user is allowed to access particular set of content and then (e.g. using native WP "wp_redirect()" function) redirect user to another site.

    You may also want to post a custom dev question at our "Jobs & Pros" job board (please note: no WPMU DEV staff involved!) here:
    https://premium.wpmudev.org/wordpress-development/

    I have a few other feature requests relating to dripped content. Is there a direct way of adding these?

    Yes. In order to post a feature request post it the same way you're creating new support tickets but from the first drop-down list in form (which by default is set to "Plugins & Themes") select "Feature Suggestions and Feedback".

    Best regards,
    Adam

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.