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™

Understanding the code...

s2Member Plugin. A Membership plugin for WordPress®.

Understanding the code...

Postby rwilki » August 16th, 2011, 2:04 pm

Hi. I'm having a bit of a hard time understanding why the variables aren't working for me.

This is my code. Shouldn't it hide the content from the level not required?
Code: Select all
<?php } elseif ($_GET['s2member_seeking'] === '0') { ?>
By registering now...
<?php } elseif ($_GET['s2member_seeking'] === '1') { ?>
By signing up for Premium Access Pass...
<?php } ?>


I've also tried...
Code: Select all
<?php } elseif ($_GET['s2member_level_required'] === '0') { ?>

and
Code: Select all
<?php } elseif ($_GET['s2member_level_required'] === '1') { ?>


I would like the MOP page to only show the option needed for access to the protected post that was clicked. Making visible ONLY the message for the required level content, not both. To me, it's confusing if both membership options show up when the visitor is just trying to get to one article.
User avatar
rwilki
Registered User
Registered User
 
Posts: 61
Joined: July 22, 2011

Re: Understanding the code...

Postby RJGonzalez » August 16th, 2011, 10:18 pm

Code: Select all
<?php } elseif ($_GET['s2member_level_required'] === '1') { ?>


I might be i am wrong but should be this way?

Code: Select all
<?php } elseif { ($_GET['s2member_level_required'] === '1') ?>


Hope that helps
Always willing to help, securely at http://www.149host.com
User avatar
RJGonzalez
Registered User
Registered User
 
Posts: 20
Joined: August 16, 2011
Location: Florida. USA

Re: Understanding the code...

Postby rwilki » August 17th, 2011, 2:25 am

Thanks for this RJ, but it didn't seem to work for me.
User avatar
rwilki
Registered User
Registered User
 
Posts: 61
Joined: July 22, 2011

Re: Understanding the code...

Postby RJGonzalez » August 17th, 2011, 3:37 am

I try, hope you get it resolved
Always willing to help, securely at http://www.149host.com
User avatar
RJGonzalez
Registered User
Registered User
 
Posts: 20
Joined: August 16, 2011
Location: Florida. USA

Re: Understanding the code...

Postby Cristián Lávaque » August 17th, 2011, 4:14 am

You start with an elseif, do you have an if before the quoted code? If not, then you should start with an if.

Code: Select all
<?php if ($_GET['s2member_level_req'] == '0') { ?>
By registering now...
<?php } elseif ($_GET['s2member_level_req'] == '1') { ?>
By signing up for Premium Access Pass...
<?php } ?>


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: Understanding the code...

Postby rwilki » August 17th, 2011, 4:49 pm

wow this is tough. i feel like I'm getting closer. when I put this code on my page or in the template for this page, none of the text within the php shows up. So the page is blank.

the "By registering now..." does not appear when seeking level#0 content and "By signing up for Premium Access Pass..." doesn't not appear when seeking level#1 content.

Is there a shortcode for this condition?
Code: Select all
<?php if ($_GET['s2member_seeking'] == '0') { ?>
and this one?
Code: Select all
<?php } elseif ($_GET['s2member_seeking'] == '1') { ?>


The idea is that this is content that appears when people are NOT logged in and they're seeking the designated content...
User avatar
rwilki
Registered User
Registered User
 
Posts: 61
Joined: July 22, 2011

Re: Understanding the code...

Postby Bruce C » August 17th, 2011, 7:58 pm

THAT problem is caused by the ===. the '0' and '1' in the single quotes turns the output to a string, which is why it is not working for you. Try taking out the quotes, as I showed you in the PM I sent you, it should work.

Hope that helps!

P.S.
Whenever the current member is NOT redirected from a page, the value defaults to a string of '0', therefore, you HAVE to use the === for the free subscribers, otherwise it will error.
~Bruce ( a.k.a. Ace )

If you're interested in a Professional Installation, or Custom Coding Job, you can send your request here.

Proud Supporter of:
The Zeitgeist Movement
and Occupy Everything
User avatar
Bruce C
Experienced User
Experienced User
 
Posts: 337
Joined: July 20, 2011

Re: Understanding the code...

Postby rwilki » August 17th, 2011, 8:25 pm

thanks Ace. Tried every configuration I can think of. Same result. Nothing. So frustrating because I know it's possible and it's probably something simple...
User avatar
rwilki
Registered User
Registered User
 
Posts: 61
Joined: July 22, 2011

Re: Understanding the code...

Postby Bruce C » August 17th, 2011, 9:04 pm

s2member_seeking looks like it's the post id. I'm looking at the code somemore, I'll get back to you if I figure it out.
~Bruce ( a.k.a. Ace )

If you're interested in a Professional Installation, or Custom Coding Job, you can send your request here.

Proud Supporter of:
The Zeitgeist Movement
and Occupy Everything
User avatar
Bruce C
Experienced User
Experienced User
 
Posts: 337
Joined: July 20, 2011

Re: Understanding the code...

Postby rwilki » August 17th, 2011, 9:13 pm

Thanks Ace. I'm surprised I'm the first person to ask about this. Seems kind of logical to me. Since s2member offers multiple levels of access, how do people know which level to signup for if all the signups fall on one page?

I love the community and plugin. Just wish I could move on...
User avatar
rwilki
Registered User
Registered User
 
Posts: 61
Joined: July 22, 2011

Re: Understanding the code...

Postby Bruce C » August 17th, 2011, 9:36 pm

Alright, so I was wrong about the strings...

Here's the solution:

Code: Select all
<?php
if (!isset ($_GET["s2member_level_req"])) {
//do nothing
}
else if ($_GET["s2member_level_req"] === "0")
   {
      echo "You need to be at least a free member to do that.";
   }
else if ($_GET["s2member_level_req"] === "1")
   {
      echo "You need to be level 1";
   }
else {
//do nothing
}
?>


Basically, you have to see if the s2member_level_req is set before you go through the conditionals.

Ace tested and approved!
~Bruce ( a.k.a. Ace )

If you're interested in a Professional Installation, or Custom Coding Job, you can send your request here.

Proud Supporter of:
The Zeitgeist Movement
and Occupy Everything
User avatar
Bruce C
Experienced User
Experienced User
 
Posts: 337
Joined: July 20, 2011

Re: Understanding the code...

Postby rwilki » August 17th, 2011, 9:48 pm

ACE!!!!! You are the man! That worked great. The logic in your conditions make sense, I wish I had thought of that.

Sorry but two final questions for you. I'm using "Shortcode Exec PHP" plugin and I had to add the "Exec-PHP" plugin for the most recent code you just posted.

1] Do you think there is a way to use shortcode or to shortcode the php for the condition?
2] More importantly, I was hoping to put a button shortcode inside the echo for people to signup for paid access. I'm guessing that there are restrictions with code inside the echo " ". Do you think I can escape certain code characters or will it just not work?

Thanks SO VERY MUCH for you awesome geniusness!!!
Bob
User avatar
rwilki
Registered User
Registered User
 
Posts: 61
Joined: July 22, 2011

Re: Understanding the code...

Postby Bruce C » August 17th, 2011, 10:05 pm

You can escape the php by just adding a ?> whenever you want the php to stop and a <?php whenever it starts again.

Code: Select all
<?php
if (!isset ($_GET["s2member_level_req"]))
   {
?>
<?php
   }
else if ($_GET["s2member_level_req"] === "0")
   {
?>
      You need to be at least a free member to do that.
<?php
   }
else if ($_GET["s2member_level_req"] === "1")
   {
?>
      You need to be level 1
<?php
   }
else
   {
?>
<?php
   }
?>
~Bruce ( a.k.a. Ace )

If you're interested in a Professional Installation, or Custom Coding Job, you can send your request here.

Proud Supporter of:
The Zeitgeist Movement
and Occupy Everything
User avatar
Bruce C
Experienced User
Experienced User
 
Posts: 337
Joined: July 20, 2011

Re: Understanding the code...

Postby Bruce C » August 17th, 2011, 10:45 pm

Also, for the Shortcode Execution, I believe that if you just use <? instead of <?php it would work with it? Otherwise, I'm not sure, I've never used that.
~Bruce ( a.k.a. Ace )

If you're interested in a Professional Installation, or Custom Coding Job, you can send your request here.

Proud Supporter of:
The Zeitgeist Movement
and Occupy Everything
User avatar
Bruce C
Experienced User
Experienced User
 
Posts: 337
Joined: July 20, 2011

Re: Understanding the code...

Postby Cristián Lávaque » August 18th, 2011, 3:03 am

rwilki wrote:I was hoping to put a button shortcode inside the echo for people to signup for paid access.


You mean something like this?

Code: Select all
<?php if ($_GET['s2member_level_req'] == '0') { ?>

By registering now...

<?php } elseif ($_GET['s2member_level_req'] == '1') { ?>

[s2Member-PayPal-Button ... /]

<?php } ?>
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 0 guests

cron