Nesting WordPress Shortcodes & Conditionals?
Posted: July 12th, 2011, 11:26 am
I am creating a teaser / blocker for certain pages & posts.
So, I will show some teaser content... and if the viewer has 'Level 1' access, then they will be shown the rest of the content. ** those that don't have access to the [pay] Premium content are shown a "blocker" message.
I understand how to do this with Simple Conditionals. However, want to take it a step further.
We are converting from another membership plugin and we already have shortcode tags in our posts written like the following:
Teaser content...
[pay]
Premium content
[/pay]
So far, using the S2Member plugin... I have figured out to do the following
Teaser content...
[s2If current_user_can(access_s2member_level1)]
Premium content...
[/s2If]
[s2If !current_user_can(access_s2member_level1)]
[blockermessage]
[/s2If]
here is my sandbox page example using the Simple Conditionals: https://museuminsider.co.uk/sandbox/sit ... y-tenders/
I created a [blocker] shortcode by adding to my functions.php -- include shortcode.php.... and then my [blocker] message is pulled from the shortcode.php
So the Question is...
Is is possible to duplicate the same using Simple or Advanced PHP conditionals... So that basically the following occurs:
[pay] = [s2If current_user_can(access_s2member_level1)]
[/pay] = [/s2If] [s2If !current_user_can(access_s2member_level1)] [blockermessage] [/s2If]
Then I don't have to change anything in the thousands of posts we have.
So, I will show some teaser content... and if the viewer has 'Level 1' access, then they will be shown the rest of the content. ** those that don't have access to the [pay] Premium content are shown a "blocker" message.
I understand how to do this with Simple Conditionals. However, want to take it a step further.
We are converting from another membership plugin and we already have shortcode tags in our posts written like the following:
Teaser content...
[pay]
Premium content
[/pay]
So far, using the S2Member plugin... I have figured out to do the following
Teaser content...
[s2If current_user_can(access_s2member_level1)]
Premium content...
[/s2If]
[s2If !current_user_can(access_s2member_level1)]
[blockermessage]
[/s2If]
here is my sandbox page example using the Simple Conditionals: https://museuminsider.co.uk/sandbox/sit ... y-tenders/
I created a [blocker] shortcode by adding to my functions.php -- include shortcode.php.... and then my [blocker] message is pulled from the shortcode.php
So the Question is...
Is is possible to duplicate the same using Simple or Advanced PHP conditionals... So that basically the following occurs:
[pay] = [s2If current_user_can(access_s2member_level1)]
[/pay] = [/s2If] [s2If !current_user_can(access_s2member_level1)] [blockermessage] [/s2If]
Then I don't have to change anything in the thousands of posts we have.