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™

Membership Options Page Variables

s2Member Plugin. A Membership plugin for WordPress®.

Membership Options Page Variables

Postby cdavignon » April 8th, 2011, 8:56 am

Hi,
On my website I would like it if a user is NOT logged in and they try to access the Membership area of my site they would get a notice saying "To access the membership area ; Please logon or requester for a free account" but, here is where I am getting lost - I can setit up so the messages will show to a NOT logged in user but, when i want the message to only show based on the PAGE name or its ID i can not get any messages on the page to show. Here is the PHP that i am trying to play with.

Code: Select all
   <?php }  else if(current_user_cannot("access_s2member_level0") && 's2member_seeking` = [post]-[986]{ ?>
        <p>Please become a free member to access the Member’s Area.</p>'
;


If I use 

Code: Select all
 <?php } else if(current_user_can("access_s2member_level0") && $_GET["s2member_ccap_req"] === "test"){ ?>
    test message


Then the "test message" is show to every one who can access level 0 and who also do not have the ccap of test. But, how do i get it so the message is show based on the page that is trying to be accessed.

thank you for any help
Last edited by Cristián Lávaque on April 8th, 2011, 1:49 pm, edited 2 times in total.
Reason: Improve code readability. http://www.primothemes.com/forums/viewtopic.php?f=36&t=2780
User avatar
cdavignon
Registered User
Registered User
 
Posts: 7
Joined: April 8, 2011

Re: Membership Options Page Variables

Postby Cristián Lávaque » April 8th, 2011, 1:56 pm

I noticed some PHP syntax errors in your first code snipet, so I made some changes that should help getting it to work.

Code: Select all
<?php } else if (current_user_cannot('access_s2member_level0') && $_GET['s2member_seeking'] === 'post-986') { ?>
    <p>Please become a free member to access the Member’s Area.</p>
<?php } ?>


Let me know if it did and if there's anything else I can help you with. :)
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: Membership Options Page Variables

Postby cdavignon » April 8th, 2011, 5:00 pm

Thank you for your help. I replaced the code and its now working :)
User avatar
cdavignon
Registered User
Registered User
 
Posts: 7
Joined: April 8, 2011

Re: Membership Options Page Variables

Postby Cristián Lávaque » April 8th, 2011, 6:04 pm

Great! :)
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: Membership Options Page Variables

Postby cdavignon » April 9th, 2011, 9:03 pm

Again Thank you for your help. I have two more php question but, frist I have a question about the download confirm pop-up ; In the documention it says this:
Whenever a logged-in Member clicks a link that contains ?s2member_file_download, the system will politely ask the user to confirm the download using a very intuitive JavaScript confirmation prompt that contains specific details about download limitations.
However, If i logon as a user it does not matter if they are at level 0 or 4 they do not get any download confrim pop-up. Is there somthing that i have to do so my users see a connfrim pop-up on downloads it looks like this should be automatic ? I am using wordpress 3.1.1 what am i doing wrong ?
Ok, Now my php questions
What I would like to do is show a message to a user who is trying to download a file that they need to upgraed say to level 1 in order to download (name of file.) Or if they are not logged in they would need to buy a level one membership.
Next I would like to redirect any user who is asked to logon or upgrade back to the post / page that they where trying to access after they logon or pay for access.
I have seen code examples for this sowhere but, after hours of looking for them again I am not able to find them so if you could s give me some code examples i can get the rest of it to work.
thank you again for all your help.
User avatar
cdavignon
Registered User
Registered User
 
Posts: 7
Joined: April 8, 2011

Re: Membership Options Page Variables

Postby Cristián Lávaque » April 11th, 2011, 10:37 pm

cdavignon wrote:However, If i logon as a user it does not matter if they are at level 0 or 4 they do not get any download confrim pop-up. Is there somthing that i have to do so my users see a connfrim pop-up on downloads it looks like this should be automatic ? I am using wordpress 3.1.1 what am i doing wrong ?


Have you edited user roles in any way with another plugin? They may be considered at Level 4 when given some capabilities, for example, which would explain why s2Member lets them download without a warning.

cdavignon wrote:What I would like to do is show a message to a user who is trying to download a file that they need to upgraed say to level 1 in order to download (name of file.) Or if they are not logged in they would need to buy a level one membership.


You can have the download link in a page set to the level you want to require, or inside a conditional block that requires the level you want, and ask the person to purchase the level if they don't have it when trying to view it. You can read about s2Member conditionals here WP Admin -> s2Member -> API / Scripting

cdavignon wrote:Next I would like to redirect any user who is asked to logon or upgrade back to the post / page that they where trying to access after they logon or pay for access.


You can have people get back to the page you specify with s2Member Pro's Pro-Forms available for the PayPal and Authorize.Net gateways. The custom return URLs feature is explained under WP Admin -> s2Member -> PayPal Pro-Forms -> Custom Return URLs On Success.

To get the member back to the page he was at before loggin in, the Pro Login Widget available in s2Member Pro has an option to have this happen. http://s2member.com

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: Membership Options Page Variables

Postby cdavignon » April 12th, 2011, 2:35 am

Thank you for your replay,
The info you have here is very helpful.
In regarderds to user roles NO user roles have been edited ; I am thinking maybe there might have been a bug with another plug in that was installed. So I disabled all but, S2 member and still no download pop-up ; I have tried to get one with a member at level 0-3 on IE , Firefox , and Google Chrome and still no downlaod pop-up warning : The files are in the S2 member files folder on my server and are protected as you can not download them unless you are logon and have the right level of access. Allthough its not that big of a deal as i am still working on my site but, maybe the ishue is just related to my install of WP or maybe its bigger then that ? or i am just crazy and am doing somthing very wrong. As i have searched through the forms to see if anyone else is alos haveing this isshue I have yet to find anyone else with this isshue so eather I am the first to notice it or I am the only one with it. I will have to install wordpress in another folder on my server and see if after a clean install of WP and S2 member i can get a dowload pop-up warning and if so then there is any ishue with my install or WP if not then there is somthing bigger going on. Again thank you for the info you provided and I will let you know the out coming of my testing - as i find it a bit odd that this auto pop-up is not working according to the way it is documented.

Now on to the PHP ;

I am allready useing PHP Scripting for my post and pages and it works grate user goes to the page and if they don't not have access get a message telling them why. However, when it comes to file access / downloads something is different. As files do not have id numbers I can't get a message to desplay to the user like I can with a post or a page. Here is the PHP i am trying to use but,i can not get a message to show ; any ides on how i can fix this ? here is the PHP code ; The part that gets me is i can't be to fare off as i don't get any systex erros and nothing shows up on the membership options page.

Code: Select all
<?php }  else if (current_user_cannot('access_s2member_level1') && $_GET['s2member_seeking'] === 'file-access&s2member_level_req=1') { ?>
The file you where trying to download ( <?php echo $file_name; ?> ) requires access @ Level #<?php echo $level_req; ?> Upgrade your account now for access.
<?php } ?>


The info that is show in the URL is this: /membership_info/?s2member_seeking=file-access-s2member-level1%2Ftest.txt&s2member_level_req=1


One to the redirection
Thank you for the info about the pro form as my site is not very big yet ; I can't see me upgrading to S2 member pro just to be able to get a user back to the post or page they where at but, its good to know that S2 member pro can do that for me and when / if my site becomes big enugh to off set the cost of S2 member pro its somthing i will think about getting.

Thank you again for all your help
User avatar
cdavignon
Registered User
Registered User
 
Posts: 7
Joined: April 8, 2011

Re: Membership Options Page Variables

Postby Cristián Lávaque » April 12th, 2011, 7:20 pm

I'm glad I was able to help you. :)

I'll ask Jason about the pop-up you're not getting.

Regarding your code, I think you have the $_GET['s2member_seeking'] value wrong. Instead of file-access, it should have the file's name.

WP Admin -> s2Member -> API / Scripting -> Membership Options Page / Variables

.../membership-options-page/?s2member_seeking=file-example.zip&s2member_level_req=1
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: Membership Options Page Variables

Postby Jason Caldwell » April 12th, 2011, 9:38 pm

Cristián is correct. Here is one way to deal with $_GET["s2member_seeking"].
Code: Select all
<?php
list($seeking, $file) = preg_split("/-/", $_GET["s2member_seeking"], 2);

if(
$seeking === "file" && $file === "example.zip"){ ?>
    The file you were trying to download ( <?php echo $file; ?> ) requires access @ Level #<?php echo $_GET["s2member_level_req"]; ?>. Upgrade your account now for access.
<?php } ?>
~ 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: Membership Options Page Variables

Postby Jason Caldwell » April 12th, 2011, 9:41 pm

cdavignon wrote:still no downlaod pop-up warning

This sounds like a JavaScript error has been introduced into your theme. Yea, try this on a fresh install of WordPress/s2Member and it should work as expected. To identify the problem in your current installation, try going up to Tools -> Error Console in Firefox after you click a link that should have spawned a popup.
~ 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: Membership Options Page Variables

Postby Cristián Lávaque » April 12th, 2011, 11:28 pm

Good point, I had not thought about that.

This video is on another problem caused by JS errors, but may help understand how to use the Error Console in Firefox.

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: Membership Options Page Variables

Postby cdavignon » April 13th, 2011, 7:33 am

I have learned a lot from the two of you.
An update on the download pop-up ; I looked for a JavaScript error using the Error Console in Firefox but, there are no errors that show up so I'm at a loss on what might be the issue with my current installation. Over the weekend I will play with a clean install of WP and S2 member to see what happens. I am determined to find out why this does not work on my installation - and as the Error Console in Firefox is not going to help me I have some fun ahead of me.

Thank you Jason for the PHP code it's exactly what I was looking for.

I have two more questions:

1. When I use the PHP code Jason gave me and a user is not logged into my website - they get a message and that’s awesome but, S2 member says that level 0 is required and not level 1 or level 2: I have a test file I put into the access-s2member-level1 and access-s2member-level2 sub directories and the files are protected with that level access if the user is logged in they see what level is required ie level 1 or 2. My question is there a way to put which level is required into my URL to the file or will S2 member always show a level 0 is required no matter which level is required if a user is not logged in ?

2. My 2ed question is how would I use the PHP code the Jason gave me with other PHP on the same page I have tried a number of different methods but, keep getting syntax errors : If I use the code without any other PHP on the page it works but, if I add PHP to the page well it’s a no go. I have a feeling it's as easy as removing a line of code or adding a } somewhere : I still have a lot to learn about PHP but, I have already learned a lot from both of you so thank you so much for helping me get started with the use of PHP and S2 member.

Thank you again for all your help
Chris
User avatar
cdavignon
Registered User
Registered User
 
Posts: 7
Joined: April 8, 2011

Re: Membership Options Page Variables

Postby Cristián Lávaque » April 13th, 2011, 4:25 pm

If you look at the example above, you'll see that the URL has the required level for the file:

.../membership-options-page/?s2member_seeking=file-example.zip&s2member_level_req=1


Isn't it in your URL when the person is not allowed to download a file? You can get that value from $_GET['s2member_level_req'].

About the syntax errors, if you have an editor with syntax highlighting, it's usually easy to see where the problem is. Also, the syntax error usually tells you more or less where the problem is.
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: Membership Options Page Variables

Postby cdavignon » April 13th, 2011, 7:43 pm

Hi Cristián,
Yes, the level 1 , 2 , and up to 4 shows up in the URL. But, if the user is not logged in. then no matter which sub-directory I use access-s2member-level1 , access-s2member-level2 , and so on the level in the URL is 0.
Here is an examle link
Http://www.cdavignon.com/?s2member_file ... 1/test.txt

and after the user click or just enters that URL into the browser and they are not logged in they get this URL

http://www.cdavignon.com/membership_inf ... evel_req=0

The 2ed URL with s2member_level_req : should show a 1 as the file is in access-s2member-level1 and as I understand it via the documentation but, it does not ?
But, if the user is logged in then this happens

they go to the above examle link and then this shows up in the URL : And now as it should a number 1 is at the end of the URL right have the level_req.

http://www.cdavignon.com/membership_inf ... evel_req=1

So I was just wondering why this was. Is there another way to give out file links ?? I have looked at the documentation and it does not apper to be any other way to give a link to a file in a sub-directory. But, if i look at the example link ?s2member_seeking=file-example.zip&s2member_level_req=1 this file does not apper to be in a sub-directory and it is showing level 1 as requried so then my question is how does one requrie level 1 , 2 and so on without useing a sub-dirctory ? As the use of sub-directories i got from the documentation as it is stated that that is how to protect level file access but, if I just look at the example link you gave me then it appers that the use of sub-dircotories is not the way to go.

And one more example link useing level 2

http://www.cdavignon.com/membership_inf ... evel_req=0

f you look at the page : it says level 0 is requried and that is show in the url. However if the user logges in it shows level 2 as its refelected in the URL. Just link in my first link above.

If i try to access a page that needs level 1 access its shown in the URL even if the user is not logged in shound this behaver not be the same for file access ? Just wondering....

Thank you for telling me about an editor with syntax highlighting ; I will have to download one.
Thank you again for all your help.
User avatar
cdavignon
Registered User
Registered User
 
Posts: 7
Joined: April 8, 2011

Re: Membership Options Page Variables

Postby Jason Caldwell » April 15th, 2011, 6:23 pm

Thanks for reporting this important issue.
~ and thanks for bringing this to my attention Cristián.
cdavignon wrote:Yes, the level 1 , 2 , and up to 4 shows up in the URL if the user is not logged in. then no matter which sub-directory I use access-s2member-level1 , access-s2member-level2 , and so on the level in the URL is 0.

Yes, this is a bug. You are correct, s2Member *should* be reporting the proper Level number in this case. The reason it's not, is because the User is not logged in, and s2Member is saying Level #0, because it expects the User to be logged in with a Level of at least zero. Which is NOT the right way to handle this.

In the current release ( at this time, s2Member v3.5.8 ), this is the case ( it's a bug ). I'm adding this to our TODO list so that this bug will be fixed in the release of s2Member v3.6+.

@TODO :: fix bug with $_GET["s2member_level_req"] and File Download Restrictions.

Unfortunately, there is no quick-fix for this, so you'll need to wait for s2Member v3.6. Sorry.
~ 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: Membership Options Page Variables

Postby cdavignon » April 16th, 2011, 12:45 pm

Hi Jason,
Cool I found a bug :) Thank you for letting me know that its a bug in S2member and not with anything that I am doing. I think for now the best "fix" would be to show a message to anyone who is trying to download files that are protected with S2member that they most login to downlaod files and a paid membership might be requried or somthing like that. Thrn any logon member would see a meesage that they don't have access and to upgrade their account if needbe. Thank you again for all your help.
User avatar
cdavignon
Registered User
Registered User
 
Posts: 7
Joined: April 8, 2011


Return to s2Member Plugin

Who is online

Users browsing this forum: Google [Bot] and 2 guests

cron