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™

MOP Variable Help

s2Member Plugin. A Membership plugin for WordPress®.

MOP Variable Help

Postby dev9833 » April 5th, 2011, 4:37 pm

Hi

First off, big thanks for all the work you've put into developing and support s2 member. Much appreciated.

I'm trying to do something pretty straightforward... I'd like to add a conditional statement to my Member Options page that basically says, if the user has arrived at the Member options page because they are not logged in, echo "you've come to this page because you are not logged in or need to become a member" followed by the rest of the page's content.

Another way to say that is, if the page has been denied, tell the user why, then give them the member options page beneath that explanation.

At this point, I only have one level of membership - paid. I don't have any level 0s, just level 1s.

I tried using
Code: Select all
<?php if($_GET["s2member_level_req"]){ ?><p>The page you were trying to view is protected. Please become a member.</p><?php } ?>
but this didn't seem to work for me .

Do I need to declare a variable first? I'm doing all of this in my template by the way, not using shortcodes or in the HTML editor using php-exec.

You help is appreciated.

Thanks.
User avatar
dev9833
Registered User
Registered User
 
Posts: 13
Joined: April 5, 2011

Re: MOP Variable Help

Postby Cristián Lávaque » April 5th, 2011, 10:20 pm

Hi!

OK, so you only have protected content set to Level 1, and that's the only level your members would have?

Then you don't need to check anything, you already know that if they were sent to the Membership Options Page it's because they tried to view Level 1 content and they weren't in a Level 1 account (either don't have it or weren't logged in).

Since you know why they were sent there, there's nothing to figure out and you can simply give the message you see fit. You don't need to check what the required Level is, you know it's 1.

Does that help or are you trying to achieve something I missed? :)
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: MOP Variable Help

Postby dev9833 » April 5th, 2011, 10:32 pm

But this page is also a general page that talks about my product. I don't want to say "You've accessed this page because you are not a member" if a user has navigated to the page directly. That would be silly. Make sense?

In other words, I *only* want this message to show if they have been redirected to the member options page because they tried to access protected content.
User avatar
dev9833
Registered User
Registered User
 
Posts: 13
Joined: April 5, 2011

Re: MOP Variable Help

Postby Cristián Lávaque » April 5th, 2011, 10:46 pm

Yeah, I get that perfectly and I think you're right about it.

Since this is the default page s2Member will send people to because of lack of access, I suggest you just use it for that.

To talk about your product or service you can create another page that isn't tied to this behaviour of s2Member. ;)
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: MOP Variable Help

Postby dev9833 » April 5th, 2011, 10:50 pm

Hmmmm....but the content is going to be exactly the same.

All I want to know is...

How can I use MOP variables to create the if statement that I outlined in my first post?

IF the user was redirected to the MOP because they were denied access, THEN display X.
User avatar
dev9833
Registered User
Registered User
 
Posts: 13
Joined: April 5, 2011

Re: MOP Variable Help

Postby Cristián Lávaque » April 6th, 2011, 12:27 am

Oh ok, I think I now understood what you want. Sorry I didn't get it before.

If you see the MOP Vars documentation WP Admin -> s2Member -> API / Scripting -> Membership Options Page / Variables, you'll notice that one variable is always passed:

`s2member_seeking` is always passed in; it is never excluded.


So you can check for that variable in the $_GET array and if it's there, you know the person got redirected to the Membership Options Page.

The your condition could go like this:

Code: Select all
<?php
if 
(isset($_GET['s2member_seeking']))
    echo '<p>The page you were trying to view is protected. Please become a member.</p>';
?>


I hope that helps you. :)
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: MOP Variable Help

Postby dev9833 » April 6th, 2011, 1:35 am

Spot on.

Thanks for sticking with me Cristian. You've made my night!

PS This seems like it could be a useful and widely used example that could be included in the MOP vars docs....
User avatar
dev9833
Registered User
Registered User
 
Posts: 13
Joined: April 5, 2011

Re: MOP Variable Help

Postby Cristián Lávaque » April 6th, 2011, 2:48 am

Thank you for reporting back. I'm glad I could help! :)

I'll mention your suggestion to Jason, seems like a good idea to document it as an example. In the meantime it'll be available to those who search the forums.
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: MOP Variable Help

Postby Jason Caldwell » April 7th, 2011, 4:28 pm

Thanks guys.

@TODO: Add a few simplified examples for MOP Vars to built-in documentation for s2Member.
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: MOP Variable Help

Postby rwilki » August 16th, 2011, 1:43 pm

Man, this would be great! Jason, a few examples of MOP variables would be great. I'm not even sure where they go? I understand the code but not the application of where it needs to be...
User avatar
rwilki
Registered User
Registered User
 
Posts: 61
Joined: July 22, 2011

Re: MOP Variable Help

Postby TotalWeb » January 16th, 2012, 5:26 pm

So you can check for that variable in the $_GET array and if it's there, you know the person got redirected to the Membership Options Page.


I kind of thought of this solution already, but that will require editing the theme, which I want to avoid. Is it possible to use a shortcode for that? Or, I guess that question is "Does such shortcode exist?". That would most definitely help make it much easier and cleaner way to implement.

Thanks!
User avatar
TotalWeb
Registered User
Registered User
 
Posts: 1
Joined: January 16, 2012


Return to s2Member Plugin

Who is online

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

cron