Tips and Tricks HQ Support Portal › Forums › WP eMember › WP-eMember nested content protection fo conditional content delivery
- This topic has 14 replies, 5 voices, and was last updated 3 years, 8 months ago by admin.
-
AuthorPosts
-
June 17, 2014 at 12:36 pm #11029FranczVMember
We require content protection based on multiple membership levels with compounded access.
For example we currently have 16 different levels to present content based on a geographic location, there are three additional variations required for each of these 16 levels, that would add extra content to each if active.
Is it possible to nest content protection shortcodes (so Group A could have a second membership level added as a conditional so additional Group A content can be displayed) or is it possible to add conditionals to the content protection shortcode based on a custom membership field.
We are aware that we can create Group A, Group A2, Group A3 etc. however this would require us to create 64 membership levels to achieve the desired result.
June 17, 2014 at 2:17 pm #63748wzpModeratorIs it possible to nest content protection shortcodes…
This is a WordPress (not an eMember) restriction…
“The shortcode parser correctly deals with nested shortcode macros, provided their handler functions support it by recursively calling do_shortcode(). However the parser will fail if a shortcode macro is used to enclose another macro of the same name.”
http://codex.wordpress.org/Shortcode_API#Nested_Shortcodes
…or is it possible to add conditionals to the content protection shortcode based on a custom membership field.
Yes, eMember does support some conditional protection:
http://www.tipsandtricks-hq.com/wordpress-membership/how-to-protect-a-section-of-a-post-or-page-88
Perhaps that might be sufficient. If not, and depending upon the complexity, we are open to suggestions.
June 17, 2014 at 4:50 pm #63749FranczVMemberSo based on the wordpress limitation, would it be straight forward to create a duplicate shortcode with a different name to enable nesting?
June 17, 2014 at 10:54 pm #63750adminKeymasterYou should be able to add secondary levels then have nested section/partial protection shortcode.
October 7, 2014 at 3:37 pm #63751phytochemMember“You should be able to add secondary levels then have nested section/partial protection shortcode.”
Could you provide an example of this?
Thanks
October 7, 2014 at 9:56 pm #63752adminKeymasterLets say, the primary level is 1 and the secondary level is 2 in this example:
[emember_protected for=1]
Whatever content goes here is only visible by members who belong to level 1
[emember_protected for=2]
Whatever content goes here is only visible by members who belong to level 1 and level 2
[/emember_protected]
[/emember_protected]
October 8, 2014 at 1:32 am #63753phytochemMemberWhat is the significance and difference of that code with this (see below closing tags):
[emember_protected for=1]
Whatever content goes here is only visible by members who belong to level 1
[/emember_protected]
[emember_protected for=2]
Whatever content goes here is only visible by members who belong to level 1 and level 2
[/emember_protected]
Thank you!
October 8, 2014 at 9:56 pm #63754adminKeymasterThe second protected block can be seen by users who have level 2 (even if they don’t have level 1).
January 4, 2021 at 8:00 pm #82224clearscopedesignParticipantHi,
We are trying to use nested content protection with shortcodes, per reply #63752 above (to make some content available only to members who have both level 1 and level 2). I copied the exact code from that reply and just changed the membership level ID’s accordingly. However, it does not seem to work for us. The second closing [/emember_protected] tag appears as text, and the content doesn’t quite get protected. Could you please help me sort out what we are doing wrong? Do we need to create a duplicate shortcode with a different name to enable nesting, as had been stated by the customer who started this thread?
Thank you!
February 19, 2021 at 10:53 pm #82579clearscopedesignParticipantHi,
Just following up here. Can you please tell me if it is possible to use nested content protection, as indicated in reply #63752 above? Or do we need to create a duplicate shortcode with a different name to enable nesting, as had been stated by the customer who started this thread?
Thank you!
February 20, 2021 at 5:54 am #82580wzpModeratorCan you please tell me if it is possible to use nested content protection, as indicated in reply #63752 above?
In order for the solution to work, you must have multiple (stacked) membership levels turned on.
- This reply was modified 3 years, 9 months ago by wzp.
February 23, 2021 at 12:43 am #82607clearscopedesignParticipantThank you –
For some reason my reply doesn’t seem to be appearing so I am trying to post it again:
We do have multiple membership levels turned on.
However, it doesn’t seem to fully work for us. The second closing [/emember_protected] tag appears as text in the content on the front end of the page.
Here is a screenshot that shows both the back end code and how the front end content appears with the second closing [/emember_protected] tag as text: [ibb.co/VCQjJKq]
Could you please tell me what we are doing wrong?
February 23, 2021 at 6:29 pm #82618adminKeymasterWordpress has made changes in recent versions which prevents some nesting shortcodes from working (when the same shortcode is nested).
It needs to be done the following way:
[emember_protected for=1] Whatever content goes here is only visible by members who belong to level 1 [/emember_protected] [emember_protected for=2] Whatever content goes here is only visible by members who belong to level 2 [/emember_protected]
You can use the “do_not_show_restricted_msg” parameter in the shortcode so all the protected blocks doesn’t get shown (to create a clean experience on the front-end). The following page explains how to use that parameter:
How to Protect a Section of a Post or Page (Partial Protection)
February 24, 2021 at 6:19 pm #82630clearscopedesignParticipantGot it, thank you for the clarification.
The reason that we want to be able to use nested content protection is in order to display content based on combinations of membership levels (for example if the user has both level 2 and level 3).
Would it be possible for us to create a duplicate content protection shortcode with a different name to enable nesting, as suggested by the other customer in reply #63749 above?
Thank you!
February 25, 2021 at 3:45 pm #82633adminKeymasterYeah that could work. Not sure if that will have any other complication since I haven’t tried it.
-
AuthorPosts
- You must be logged in to reply to this topic.