PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

Simple Shortcode Conditionals - Is this right?

s2Member Plugin. A Membership plugin for WordPress®.

Simple Shortcode Conditionals - Is this right?

Postby Theresap » January 2nd, 2012, 8:20 pm

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
User avatar
Theresap
Registered User
Registered User
 
Posts: 29
Joined: March 26, 2011

Re: Shortcode Conditionals -

Postby Theresap » January 3rd, 2012, 4:45 pm

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!
User avatar
Theresap
Registered User
Registered User
 
Posts: 29
Joined: March 26, 2011

Re: Simple Shortcode Conditionals - Is this right?

Postby Raam Dev » January 3rd, 2012, 4:47 pm

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]
Raam Dev || Wherever you are, be there. || Please rate s2Member!
User avatar
Raam Dev
Developer
Developer
 
Posts: 810
Joined: October 26, 2011

Re: Simple Shortcode Conditionals - Is this right?

Postby Theresap » January 3rd, 2012, 5:24 pm

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!
User avatar
Theresap
Registered User
Registered User
 
Posts: 29
Joined: March 26, 2011

Re: Simple Shortcode Conditionals - Is this right?

Postby Eduan » January 3rd, 2012, 5:29 pm

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. :)
Now officially accepting Professional s2Member installations along with Bruce C (a.k.a. Ace).

If you're interested in a Professional s2Member Installation, or a Custom Coding Job, you can send your request here.
User avatar
Eduan
Experienced User
Experienced User
 
Posts: 1154
Joined: August 27, 2011
Location: Taxco de Alarcón, Guerrero, México.

Re: Simple Shortcode Conditionals - Is this right?

Postby Theresap » January 3rd, 2012, 5:47 pm

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!
Attachments
s2mem.PNG
s2mem.PNG (14.94 KiB) Viewed 311 times
User avatar
Theresap
Registered User
Registered User
 
Posts: 29
Joined: March 26, 2011

Re: Simple Shortcode Conditionals - Is this right?

Postby Raam Dev » January 3rd, 2012, 6:23 pm

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]
Raam Dev || Wherever you are, be there. || Please rate s2Member!
User avatar
Raam Dev
Developer
Developer
 
Posts: 810
Joined: October 26, 2011

Re: Simple Shortcode Conditionals - Is this right?

Postby Theresap » January 3rd, 2012, 6:44 pm

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
User avatar
Theresap
Registered User
Registered User
 
Posts: 29
Joined: March 26, 2011

Re: Simple Shortcode Conditionals - Is this right?

Postby Raam Dev » January 4th, 2012, 5:46 pm

You're most welcome, Theresa! Glad to hear you got it working. :) Let us know if there's anything else we can help with!
Raam Dev || Wherever you are, be there. || Please rate s2Member!
User avatar
Raam Dev
Developer
Developer
 
Posts: 810
Joined: October 26, 2011

Re: Simple Shortcode Conditionals - Is this right?

Postby Theresap » January 16th, 2012, 4:09 pm

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?
User avatar
Theresap
Registered User
Registered User
 
Posts: 29
Joined: March 26, 2011

Re: Simple Shortcode Conditionals - Is this right?

Postby Theresap » January 16th, 2012, 4:26 pm

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 !
User avatar
Theresap
Registered User
Registered User
 
Posts: 29
Joined: March 26, 2011

Re: Simple Shortcode Conditionals - Is this right?

Postby Raam Dev » January 16th, 2012, 10:38 pm

Thank you for the update. Glad you got it working! :)
Raam Dev || Wherever you are, be there. || Please rate s2Member!
User avatar
Raam Dev
Developer
Developer
 
Posts: 810
Joined: October 26, 2011


Return to s2Member Plugin

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot] and 1 guest

cron