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 WordPress.org. See: new forums @ WordPress.org

Login Redirect not working

s2Member Plugin. A Membership plugin for WordPress®.

Login Redirect not working

Unread postby denvert » October 12th, 2011, 9:46 pm

I'm using a login redirect with this shortcode in the form "login_redirect" => "%%previous%%", and it is not working. If I use "login_redirect" => "www.example.com", this works, however the previous shortcode does not.

I'm using pro plugin on a multisite and just updated to latest version of wordpress and the pro plugin. My login was also not working for a few hours and just start working all of a sudden. Seems like there might be some bugs with multisite and latest updates.

Please advise, need this up and working asap.
Last edited by denvert on October 13th, 2011, 9:22 am, edited 1 time in total.
User avatar
denvert
Registered User
Registered User
 
Posts: 57
Joined: March 25, 2011

Re: Login Redirect not working

Unread postby denvert » October 12th, 2011, 9:48 pm

full code:

Code: Select all
<?php

    $options 
= array(
        
"title" => "",         
    
"signup_url" => "http://xxx.xxxxxx.org/register/",          
    
"login_redirect" => "%%previous%%",          
    
"profile_title" => "",  
    
"display_gravatar" => "0",                
    
"link_gravatar" => "0",                   
    
"display_name" => "0",                   
    
"logged_in_code" => "",                  
    
"logout_redirect" => "http://xxx.xxxxxx.org",         
    
"my_account_url" => "0",      
    
"my_profile_url" => "0"      
    
);
    
$args = array (
        
"before_widget" => "<div class=\"member_login_widget\">",
        
"after_widget" => "</div>",
        
"before_title" => "<h5>",
        
"after_title" => "</h5>"
    
);
    echo 
s2member_pro_login_widget($options$args);
?>
Last edited by Cristián Lávaque on October 31st, 2011, 11:45 pm, edited 1 time in total.
Reason: Improve code readability. http://www.primothemes.com/forums/viewtopic.php?f=36&t=2780
User avatar
denvert
Registered User
Registered User
 
Posts: 57
Joined: March 25, 2011

Re: Login Redirect not working

Unread postby denvert » October 13th, 2011, 2:33 am

Login re-direct issue is happening still.

If i'm on this page, /wp-login.php and click the register link it re-directs to the home site's login page which gives an error message stating registration is turned off. This all worked before.

Just tried reverting back to an old version, no luck.

Just to note I manually changed all the pages that you need to change for multiste, get error message when try to change automatically.
User avatar
denvert
Registered User
Registered User
 
Posts: 57
Joined: March 25, 2011

Re: Login Redirect not working

Unread postby denvert » October 13th, 2011, 9:45 am

I'm adding more details after researching forums more, this ticket, viewtopic.php?f=4&t=14373&p=30196&hilit=Registration+has+been+disabled.#p30196 talks about sub-domain vs. sub directory installations, i am in a sub-domain install, however, everything was working until I did the recent upgrades.

This post talks about creating new installation to test, viewtopic.php?f=4&t=15431&p=44898&hilit=Registration+has+been+disabled.#p44898 which i really don't have the time to do, plus wouldn't really help because as noted in the post the problem would still re-appear when exporting database.

Registration does work with registration form embedded in a page, however when logging out from back end the page re-directs to default wordpress login and if i hit register link there it takes me to the registration is disabled error.
User avatar
denvert
Registered User
Registered User
 
Posts: 57
Joined: March 25, 2011

Re: Login Redirect not working

Unread postby denvert » October 17th, 2011, 12:08 pm

Hi,

Can someone please help. I was able to resolve the issue with logins but re-direct is either not working or i don't understand what it's supposed to do.

If i go to a page that is protected by s2 member and then am redirected to a login page and then login does it take me to the page that originally re-directed me with %%previous%%" as the shortcode. If not is there a way to have this set up.

Thanks
User avatar
denvert
Registered User
Registered User
 
Posts: 57
Joined: March 25, 2011

Re: Login Redirect not working

Unread postby Jason Caldwell » October 17th, 2011, 7:10 pm

Thanks for your patience.
Investigating now.
~ 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: Login Redirect not working

Unread postby denvert » October 18th, 2011, 12:54 pm

ok, let me know.
User avatar
denvert
Registered User
Registered User
 
Posts: 57
Joined: March 25, 2011

Re: Login Redirect not working

Unread postby denvert » October 19th, 2011, 11:07 pm

Hi Jason, were you able to look into this?
User avatar
denvert
Registered User
Registered User
 
Posts: 57
Joined: March 25, 2011

Re: Login Redirect not working

Unread postby denvert » October 20th, 2011, 3:34 pm

There is another recent thread that had a response, viewtopic.php?f=4&t=2717&hilit=redirect+to+last+page, it says

"That's why I pointed you to the Membership Options Page Variables, because they tell you what the person tried to view that got him sent to the Membership Options Page. You can use these variables to create a redirection URL to send the person to after login.

You can point the person to the login page with the redirection value at the end, like http://example.com/wp-login.php?redirec ... tectedpage"

I wasn't able to understand the options variables. It seems an example of how to set up would be very appreciated by a good amount of people. I think it is basic user experience in a lot of memberships sites that when you are re-directed to a page to login you are then returned to the page that you were originally directed from.

Please respond, even if it is just to say that you are not going look into this for me.
User avatar
denvert
Registered User
Registered User
 
Posts: 57
Joined: March 25, 2011

Re: Login Redirect not working

Unread postby Jason Caldwell » October 20th, 2011, 3:37 pm

Thanks for your patience once again.

OK, this configurable option that you mentioned in your first post:
Code: Select all
"login_redirect" => "%%previous%%",
This is designed to configure the s2Member Pro Login Widget, whether it be through your Dashboard, or through a PHP code snippet, as documented here.

When you use %%previous%%, it instructs s2Member to redirect a User/Member who logs into your site, specifically through the s2Member Pro Login Widget, to be immediately redirected ( after logging in ), to the page they were on previously ( i.e. the page where the Pro Login Widget appeared ).

If the Pro Login Widget appears in a Sidebar for your WordPress theme, that could be just about page on your site, which is what makes the %%previous%% Replacement Code so powerful ( i.e. a Customer can be redirected back to the page there were attempting to view, which may have required an account to view ). There is one exception that s2Member treats differently though, and that is your Membership Options Page. If a Customer attempts to log into your site from your Membership Options Page, the %%previous%% Replacement Code is ignored, and instead the Customer will be returned to your Login Welcome Page by default. This is the intended behavior, in this one special scenario, because returning a logged-in User to a set of Membership Options is not intuitive.

You've also said that...
If i'm on this page, /wp-login.php and click the register link it re-directs to the home site's login page which gives an error message stating registration is turned off. This all worked before.
This is unrelated to the %%previous%% Replacement Code. Is s2Member activated Network-wide on your installation? Or is it activated only on specific Blogs? In either case, is Open Registration enabled for all sites in your Network, or only for the Main Site?
~ 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: Login Redirect not working

Unread postby denvert » October 20th, 2011, 3:53 pm

Jason,

2nd part was another issue which has since been resolved, was a problem with re-writing multi-site files after wordpress upgrade.

Here is scenario, I have a video page with nothing on it but a video (no sidebar etc.), user is sent to re-directed to login page that has code generated from the document you give link to, specifically,

<?php
$options = array(
"title" => "",
"signup_url" => "http://xxx.xxxxxx.org/register/",
"login_redirect" => "%%previous%%",
"profile_title" => "",
"display_gravatar" => "0",
"link_gravatar" => "0",
"display_name" => "0",
"logged_in_code" => "",
"logout_redirect" => "http://xxx.xxxxxx.org",
"my_account_url" => "0",
"my_profile_url" => "0"
);
$args = array (
"before_widget" => "<div class=\"member_login_widget\">",
"after_widget" => "</div>",
"before_title" => "<h5>",
"after_title" => "</h5>"
);
echo s2member_pro_login_widget($options, $args);
?>

It does not, however re-direct to page that sent them there but re-directs to home page.

Am i misunderstanding something?
User avatar
denvert
Registered User
Registered User
 
Posts: 57
Joined: March 25, 2011

Re: Login Redirect not working

Unread postby Jason Caldwell » October 20th, 2011, 4:05 pm

Thanks for the follow-up.

You said...
user is sent to re-directed to login page that has code generated from the document you give link to, specifically,
* Can you elaborate just a bit further for me please?
Is this page a redirection? Sorry, just want to be sure I understand completely.

The %%previous%% Replacement Code works like this internally.
Code: Select all
$redirect_to = preg_replace ("/%%previous%%/i", $_SERVER["REQUEST_URI"], ($redirect_to = $options["login_redirect"])); 
~ 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: Login Redirect not working

Unread postby denvert » October 20th, 2011, 4:17 pm

Sorry just re-read your question, login page from the page they are initially being re-directed to is a login page (set as membership options page).
User avatar
denvert
Registered User
Registered User
 
Posts: 57
Joined: March 25, 2011

Re: Login Redirect not working

Unread postby Jason Caldwell » October 20th, 2011, 4:32 pm

Gotchya. Yea, I think this problem you're having is in the way you've integrated your "Login Page".

Just to clarify...
All roads to log into your site, lead to /wp-login.php ( it's your universal "Login Page" ). The s2Member Pro Login Widget makes it possible to place a Pro Login Widget/Form on any page of your site, but this Pro Login Widget/Form still posts data to /wp-login.php.

The %%previous%% Replacement Code records the section of your site where the Pro Login Widget is used. This data is sent to /wp-login.php, and upon the User's login data being processed successfully, the User/Member is redirected back to the page they were viewing previously.

Some additional confusion might be occurring in your case as well, since you're placing the Pro Login Widget on your Membership Options Page. s2Member treats this page just bit differently with respect to the %%previous%% Replacement Code:
Jason Caldwell wrote:There is one exception that s2Member treats differently though, and that is your Membership Options Page. If a Customer attempts to log into your site from your Membership Options Page, the %%previous%% Replacement Code is ignored, and instead the Customer will be returned to your Login Welcome Page by default. This is the intended behavior, in this one special scenario, because returning a logged-in User to a set of Membership Options is not intuitive.


In your case, you can accomplish what you need, but I recommend doing it this way.
Code: Select all
"login_redirect" => $_SERVER["HTTP_REFERER"] 
* ( i.e. the page that referred them to your own custom login page )
~ 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: Login Redirect not working

Unread postby denvert » October 20th, 2011, 4:49 pm

Sorry to be just a pain,

if i replace, "login_redirect" => "%%previous%%",
with

"login_redirect" => $_SERVER["HTTP_REFERER"]

just shows a blank white page.


also this doesn't make sense

"This is the intended behavior, in this one special scenario, because returning a logged-in User to a set of Membership Options is not intuitive."

I'm not trying to return them to the page they logged in from but the page that directed them to the page they logged in from. Does that make sense?
User avatar
denvert
Registered User
Registered User
 
Posts: 57
Joined: March 25, 2011

Re: Login Redirect not working

Unread postby Jason Caldwell » October 20th, 2011, 4:55 pm

Thanks for the reply.

A blank white page would indicate a PHP parse error.
Please be sure that you have a comma at the end of that line.
Code: Select all
"login_redirect" => $_SERVER["HTTP_REFERER"], 

I'm not trying to return them to the page they logged in from but the page that directed them to the page they logged in from. Does that make sense?
Right, but since you're redirecting Visitors to your own custom "Login Page" constructed with the s2Member Pro Login Widget, you need to record the page they came from "before" they were redirected to your custom "Login Page", which is not the same thing as %%previous%%. You can read more about $_SERVER["HTTP_REFERER"] here: http://php.net/manual/en/reserved.variables.server.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: Login Redirect not working

Unread postby denvert » October 20th, 2011, 5:01 pm

Wasn't a blank white page, the part that was getting embedded is not showing up but the header, sidebar etc are.
User avatar
denvert
Registered User
Registered User
 
Posts: 57
Joined: March 25, 2011

Re: Login Redirect not working

Unread postby denvert » October 20th, 2011, 5:04 pm

Code: Select all
<?php
$options = array(
"title" => "",
"signup_url" => "http://xxx.xxxxxx.org/register/",
"login_redirect" => "$_SERVER["HTTP_REFERER"]",
"profile_title" => "",
"display_gravatar" => "0",
"link_gravatar" => "0",
"display_name" => "0",
"logged_in_code" => "",
"logout_redirect" => "http://xxx.xxxxxx.org",
"my_account_url" => "0",
"my_profile_url" => "0"
);
$args = array (
"before_widget" => "<div class=\"member_login_widget\">",
"after_widget" => "</div>",
"before_title" => "<h5>",
"after_title" => "</h5>"
);
echo s2member_pro_login_widget($options, $args);
?>
User avatar
denvert
Registered User
Registered User
 
Posts: 57
Joined: March 25, 2011

Re: Login Redirect not working

Unread postby Jason Caldwell » October 20th, 2011, 5:06 pm

Thank you. Please remove the double quotes here:
Code: Select all
"login_redirect" => "$_SERVER["HTTP_REFERER"]",

Code: Select all
"login_redirect" => $_SERVER["HTTP_REFERER"], 
~ 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: Login Redirect not working

Unread postby denvert » October 20th, 2011, 5:11 pm

sorry, "login_redirect" => $_SERVER["HTTP_REFERER"], this shows login form again but still just re-directing to home page.
User avatar
denvert
Registered User
Registered User
 
Posts: 57
Joined: March 25, 2011

Re: Login Redirect not working

Unread postby Jason Caldwell » October 20th, 2011, 5:18 pm

Try to echo the value of $_SERVER["HTTP_REFERER"] on your custom Login Page.
Is this data being populated by your installation of PHP?
Code: Select all
<?php echo $_SERVER["HTTP_REFERER"]; ?>

Depending on how you're doing the redirection, it may not get populated. If that's the case, you may need to pass this information through your custom redirection instead. In other words, you might need to pass the URI of the page the Visitor was on "before" you redirect them.

Example:
When you redirect a visitor, add this to your redirection URL:
Code: Select all
http://example.com/my-custom-login-page/?previous=<?php echo urlencode($_SERVER["REQUEST_URI"]); ?>

Then, you might do something like this in your Pro Login Widget implementation:
Code: Select all
"login_redirect" => $_GET["previous"], 
~ 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: Login Redirect not working

Unread postby denvert » October 20th, 2011, 5:28 pm

Sorry i don't understand how this would could implemented in the widget replacement code, the re-direction is being created by the membership options page?

Does it help to take a step back and re-evaluate what i'm trying to do?

I try to enter a page that is protected by S2, it re-directs to a page with a link to the register page or the attached login form below. When the person logs in they are logged in to the page that they were initially trying to access before being "re-directed" or sent (whatever we should be call it) by s2.

The client's experience was they sent out an e-mail to protected page, e-mail recipient is then re-directed to login page, they then land on a seperate page then the one they were initially trying to access but another page which they then had to go back to e-mail to copy the url and re-enter it.
User avatar
denvert
Registered User
Registered User
 
Posts: 57
Joined: March 25, 2011

Re: Login Redirect not working

Unread postby Jason Caldwell » October 20th, 2011, 7:01 pm

Thanks. I understand.
Before I add another reply, can you please clarify the following for me?

Are you handling the redirection yourself through a script that you've written?
Or, are you depending on the redirection that s2Member does ( i.e. to your Membership Options Page ) when a visitor attempts to access protected content without being logged-in?
~ 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: Login Redirect not working

Unread postby denvert » October 20th, 2011, 10:29 pm

I'm depending on the re-direction that s2member does.
User avatar
denvert
Registered User
Registered User
 
Posts: 57
Joined: March 25, 2011

Re: Login Redirect not working

Unread postby Jason Caldwell » October 21st, 2011, 1:37 pm

denvert wrote:I'm depending on the re-direction that s2member does.

Thank you. OK, I see what you're dealing with now. I'm adding this to our TODO list for the next release. I'll see if we can get the %%previous%% Replacement Code working on this special page (in the way you're describing) so that others do not have this same confusion.

The next release should be available early next week. Until then, if you need a solution to this problem immediately, you may want to seek assistance from a PHP developer. Point them to this thread, and with the information I've posted above, they should be able to get this working for you.

s2Member® / Hot Tip: ( s2Installs.com! )

Recommended by s2Member® Lead Developer (Jason Caldwell). Their rate for a standard installation is $125. They're highly trained. Just request their service!

Need Help? Post A New Job!

It's free. Your Job will appear here, and @ jobs.wordpress.net. It will be displayed for a period of 21 days; or until you take it off, whichever comes first. Good luck!
~ 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

Next

Return to s2Member Plugin

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot] and 5 guests

cron