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™

scripting problem

s2Member Plugin. A Membership plugin for WordPress®.

scripting problem

Postby clubdesleaders » June 18th, 2011, 7:43 am

Good Morning,

I have 2 levels of membership :
Level 0
Level 1 with custom capabilities. One of the capabilities is vip. and the vip can download their bonuses. Other members no.
I write down this script; everything is working fine but I have an error. Member level 0 can access VIP bonus. What did I right wrong? Can anyone help me with this? Thanks

Code: Select all
<h1 style="text-align: center;">Bienvenue, <code>[s2Get constant="S2MEMBER_CURRENT_USER_DISPLAY_NAME" /].</code>dans votre espace personnel<span style="color: #000066;">
</span></h1>
<h2 style="text-align: center;"><span style="color: #339966;">Vous trouverez dans cette espace toutes les informations relatives à votre adhésion et vous pourrez également, si vous le souhaitez, changez votre mot de passe, mettre à jour votre abonnement ou télécharger vos bonus.</span></h2>
<p style="text-align: left;">Actuellement vous avez accès au statut de <code> [s2Get constant="S2MEMBER_CURRENT_USER_ACCESS_LABEL" /].</code></p>
<p style="text-align: left;">[s2If current_user_cannot(access_s2member_level1)]</p>
[_s2If current_user_can(access_s2member_ccap_vip)]
<p style="text-align: left;">Pour pouvoir bénéficier de tous les avantages des membres V.I.P,  passez au niveau supérieur.</p>
<p style="text-align: left;"><a href="  https://www.club-des-leaders.com/formulaire" target="_blank"><img class="aligncenter size-full wp-image-2229" title="btn_subscribeCC_LG" src="http://www.club-des-leaders.com/wp-content/uploads/btn_subscribeCC_LG.gif" alt="" width="172" height="47" /></a></p>
<p style="text-align: center;"><em><span style="text-decoration: underline;"><strong>P.S</strong></span>: Si vous souhaitez changez votre mot de passe, n'oubliez surtout pas de le réinscrire deux fois</em>.</p>
&nbsp;
<iframe src="http://www.club-des-leaders.com/?s2member_profile=1" scrolling="auto" style="width:100%; height:325px; border:1px solid #CCA94B;"></iframe>
&nbsp;
[s2If current_user_can(access_s2member_level1)]
<h4><span style="text-decoration: underline;"><em><strong>Voici vos bonus:</strong></em></span></h4>
[_s2If current_user_can(access_s2member_ccap_vip)]
<a href="http://www.club-des-leaders.com/?s2member_file_download=bonus/GuideetudeHRP.pdf" target="_blank">Étude autour de l'homme est le reflet de vos pensées. (Cliquez sur le lien et sauvegardez)</a>

<a href="http://www.club-des-leaders.com/?s2member_file_download=bonus/RDRetmanuel.pdf" target="_blank">Réfléchissez et Devenez Riche - Livre et Manuel d'apprentissage. (Cliquez et sauvegardez)</a>
[/s2If]

[s2If current_user_can(access_s2member_level1)]
<h3><span style="color: #000066;">Si vous souhaitez annulez votre adhésion, cliquez sur la bouton ci-dessous:</span></h3>
<a style="outline: none;" href="https://www.paypal.com/cgi-bin/webscr?cmd=_subscr-find&amp;alias=agnes@agnesboukaram.com">
<img style="width: auto; height: auto; border: 0pt none;" src="http://www.club-des-leaders.com/wp-content/uploads/btn_unsubscribe_LG.gif" alt="PayPal®" />
</a>[/s2If]
Last edited by Cristián Lávaque on June 18th, 2011, 1:14 pm, edited 1 time in total.
Reason: Improve code readability. http://www.primothemes.com/forums/viewtopic.php?f=36&t=2780
User avatar
clubdesleaders
Registered User
Registered User
 
Posts: 23
Joined: February 22, 2011

Re: scripting problem

Postby Cristián Lávaque » June 18th, 2011, 1:38 pm

I removed everything except the conditional shortcodes so you can see easier what the problem can be:

Code: Select all
[s2If current_user_cannot(access_s2member_level1)]

[_s2If current_user_can(access_s2member_ccap_vip)]

[s2If current_user_can(access_s2member_level1)]

[_s2If current_user_can(access_s2member_ccap_vip)]

[/s2If]

[s2If current_user_can(access_s2member_level1)]

[/s2If]


The nesting is not correct. Only the last condition there is fine.

If you start an s2If, you need to close it before opening a new s2If. To open an s2If inside an open one you prefix it with an underdash like this _s2If.

You can't cross them like starting an s2If, then an _s2If, then closing the s2If, and then the _s2If. That's not nesting, the nested one has to be opened and closed inside the parent one.

And you have to close the ones you open.

WP Admin -> s2Member -> API / Scripting -> Using Simple Conditionals

I hope that helps. :)
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: scripting problem

Postby clubdesleaders » June 18th, 2011, 4:09 pm

Thanks but I till now I didn't understand what's wrong? Can you show me what's wrong?
User avatar
clubdesleaders
Registered User
Registered User
 
Posts: 23
Joined: February 22, 2011

Re: scripting problem

Postby Cristián Lávaque » June 18th, 2011, 11:55 pm

Code: Select all
[s2If current_user_cannot(access_s2member_level1)]
Opened first s2If.

[_s2If current_user_can(access_s2member_ccap_vip)]
Opened a nested _s2If.

[s2If current_user_can(access_s2member_level1)]
Opened a second s2If, without having closed the first one (including the nested _s2If).

[_s2If current_user_can(access_s2member_ccap_vip)]
Opened a second _s2If without having closed the previous _s2If.

[/s2If]
Closed the first s2If.

[s2If current_user_can(access_s2member_level1)]
Then you opened a third s2If, with all the above still open.

[/s2If]
Closed the second s2If.


I don't even know how WordPress would parse that since the nesting is all off, but it's to be expected that they won't work right and thus you'll have trouble like free members viewing content not meant for them.

Without knowing how you actually want the logic to go, if I am shown the above to fix the nesting, I'd do this:

Code: Select all
[s2If current_user_cannot(access_s2member_level1)]
  [_s2If current_user_can(access_s2member_ccap_vip)]
  [/_s2If]
[/s2If]

[s2If current_user_can(access_s2member_level1)]
  [_s2If current_user_can(access_s2member_ccap_vip)]
  [/_s2If]
[/s2If]

[s2If current_user_can(access_s2member_level1)]
[/s2If]


This may help understand better how to do it, so you use it the way you prefer in your page.
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: scripting problem

Postby clubdesleaders » June 19th, 2011, 8:10 am

Thank you! It's clear now.
User avatar
clubdesleaders
Registered User
Registered User
 
Posts: 23
Joined: February 22, 2011

Re: scripting problem

Postby Cristián Lávaque » June 19th, 2011, 11:44 am

:)
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010


Return to s2Member Plugin

Who is online

Users browsing this forum: No registered users and 1 guest

cron