Page 1 of 1
Simple Shortcode Conditionals - Is this right?

Posted:
January 2nd, 2012, 8:20 pm
by Theresap
Hello,
I'm wanting to set up shortcode conditionals on the member page, the level is the same, just the capabilities are different.
I want both subscriptions to show but only the 'add this subscription' to show if they don't have it. So if they have sub two there is no reason for the add sub two to show.
[s2If current_user_can(access_s2member_level1)]
Subscription one
[_s2If current_user_can(access_s2member_ccap_sub_one)]
Add (upgrade) to subscription two (I only want members with subscription one to see this)
[/s2If]
[s2If current_user_can(access_s2member_level1)]
Subscription two
[_s2If current_user_can(access_s2member_ccap_sub_two)](I only want members with subscription two to see this)
Add subscription one
[/s2If]
If they already have both, can it be written that neither 'add this subscription' shows? Also, can it be written for only the subscription link the member has signed up for to show (ex. if they don't have sub one, just show sub two and the option to add sub one) Instead of having all the subscriptions show and after clicking they get the sign up button?
Thanks for such a flexible plugin, I hope I didn't sound too confused! Appreciate your help. Theresa
Re: Shortcode Conditionals -

Posted:
January 3rd, 2012, 4:45 pm
by Theresap
Here is what I'm trying to do, maybe the last post was confusing.
Both the Journal and Tea Times are level one. I want the upgrade to show on the one they don't have, and nothing to show for the ones they do. Is there any way to do this? I've made a test member and just can't get it right.
(I got how to make only level 2 show if they order both.)
[s2If current_user_is(s2member_level1)]
The Joyous Home Journal
[_s2If current_user_cannot(access_s2member_ccap_teatimes)]
Upgrade and add the Tea Times
[/s2If]
[s2If current_user_is(s2member_level1)]
The Tea Times
[_s2If current_user_cannot(access_s2member_ccap_jhjournal)]
Upgrade and add The Joyous Home Journal
[/s2If]
Thank you!
Re: Simple Shortcode Conditionals - Is this right?

Posted:
January 3rd, 2012, 4:47 pm
by Raam Dev
Hi Theresa,
You almost got it. You need to close any opening
[s2If]'s with
[/s2If]. Also, I noticed you had an underline character in two of your IF blocks that shouldn't be there:
[_s2If current_user_can.
So here's the corrected code:
- Code: Select all
[s2If current_user_can(access_s2member_level1)]
Subscription one
[s2If current_user_can(access_s2member_ccap_sub_one)]
Add (upgrade) to subscription two
[/s2If]
[/s2If]
[s2If current_user_can(access_s2member_level1)]
Subscription two
[s2If current_user_can(access_s2member_ccap_sub_two)]
Add subscription one
[/s2If]
[/s2If]
Re: Simple Shortcode Conditionals - Is this right?

Posted:
January 3rd, 2012, 5:24 pm
by Theresap
Thanks, I still think I'm doing something wrong. I got the error:
Fatal error: s2If, malformed conditional [ current_user_can(access_s2member_ccap_jhjournal ]
Here is what I used:
[s2If current_user_can(access_s2member_level1)]
The Joyous Home Journal
[s2If current_user_can(access_s2member_ccap_jhjournal]
Upgrade and add the Tea Times
[/s2If]
[/s2If]
[s2If current_user_can(access_s2member_level1)]
The Tea Times
[s2If current_user_can(access_s2member_ccap_teatimes]
Upgrade and add The Joyous Home Journal
[/s2If]
[/s2If]
I think it would be better if it stated that if you cannot access the custom capability then show the upgrade section? Instead of it saying if you can access this one, add the upgrade? Thank you for your help!
Re: Simple Shortcode Conditionals - Is this right?

Posted:
January 3rd, 2012, 5:29 pm
by Eduan
You missed two closing parentheses, the correct code would be:
[s2If current_user_can(access_s2member_level1)]
The Joyous Home Journal
[s2If current_user_can(access_s2member_ccap_jhjournal)]
Upgrade and add the Tea Times
[/s2If]
[/s2If]
[s2If current_user_can(access_s2member_level1)]
The Tea Times
[s2If current_user_can(access_s2member_ccap_teatimes)]
Upgrade and add The Joyous Home Journal
[/s2If]
[/s2If]
Hope this helps.

Re: Simple Shortcode Conditionals - Is this right?

Posted:
January 3rd, 2012, 5:47 pm
by Theresap
Thank you! Ok, so the image is attached as to what this is showing. This still isn't right ! I can't figure out how to get it to say, if you have this one, upgrade to the other - and not have the other show? Plus the extra [/s2If] are showing on the page. Thanks again!
Re: Simple Shortcode Conditionals - Is this right?

Posted:
January 3rd, 2012, 6:23 pm
by Raam Dev
OK, the problem is that you're showing "The Joyous Home Journal" and "The Tea Times" to anyone who has Level 1 access, not just people with Level 1 access AND a specific Custom Capability.
I've modified the code below to fix that:
- Code: Select all
[s2If current_user_can(access_s2member_level1)]
[s2If current_user_can(access_s2member_ccap_jhjournal)]
The Joyous Home Journal
Upgrade and add the Tea Times
[/s2If]
[/s2If]
[s2If current_user_can(access_s2member_level1)]
[s2If current_user_can(access_s2member_ccap_teatimes)]
The Tea Times
Upgrade and add The Joyous Home Journal
[/s2If]
[/s2If]
A more simple way to write the above code would be like this:
- Code: Select all
[s2If current_user_can(access_s2member_level1) AND current_user_can(access_s2member_ccap_jhjournal)]
The Joyous Home Journal
Upgrade and add the Tea Times
[/s2If]
[s2If current_user_can(access_s2member_level1) AND current_user_can(access_s2member_ccap_teatimes)]
The Tea Times
Upgrade and add The Joyous Home Journal
[/s2If]
Re: Simple Shortcode Conditionals - Is this right?

Posted:
January 3rd, 2012, 6:44 pm
by Theresap
Yay! Working just perfect! I looked on how to say AND and couldn't figure it out ( the instructions are good, it's just the way I think) So any content between conditionals doesn't say 'and' which is what I was thinking. Thank you so much for your help!
Theresa
Re: Simple Shortcode Conditionals - Is this right?

Posted:
January 4th, 2012, 5:46 pm
by Raam Dev
You're most welcome, Theresa! Glad to hear you got it working.

Let us know if there's anything else we can help with!
Re: Simple Shortcode Conditionals - Is this right?

Posted:
January 16th, 2012, 4:09 pm
by Theresap
Hi again, I need a little more help! I need the above information to NOT show anything to the level 2 members except these lines below and this is the code I have around it:
[s2If current_user_is(s2member_level2)]
Your Subscriptions:
The Joyous Home Journal
The Tea Times
[/s2If]
What do I need to add to the above code (the code in the previous post) to say don't show to level 2? Can that be done?
Then, is the code correct below for just level 2 to see?
Re: Simple Shortcode Conditionals - Is this right?

Posted:
January 16th, 2012, 4:26 pm
by Theresap
I think I got it! Sorry to bug you! I did this:
[s2If current_user_can(access_s2member_level1) AND current_user_can(access_s2member_ccap_jhjournal) AND current_user_cannot(access_s2member_level2)]
it seems to be working right:) Thanks !
Re: Simple Shortcode Conditionals - Is this right?

Posted:
January 16th, 2012, 10:38 pm
by Raam Dev
Thank you for the update. Glad you got it working!
