How to Redirect User to Same Page User was on After Login

Hi all,

Before installing s2Member, my theme would redirect a user to the same page they were on after logging in. This is very convenient because our website is more of a forum-based community and if a person wants to respond to a topic they will be redirected to that same topic after logging in. Also, we do not - as of now - find a reason for us to have a user be redirected to a welcome page after logging in.

How would I accomplish this through s2Member>General Options> Login Welcome Page? What URL redirect would I need to fill in in order to recreate that same execution? Would this be more of a PHP execution? If so, I would not know where to implement that into the plugin?

Thanks and regards,

Josh

Hi Josh.

Did you try leaving that setting blank?

:slight_smile:

You can do that - but I would not recommend it this way. Better set the login wellcome page - then on the s2member pro login widet - set it to not redirect you anywhere.

That way if someone logs in via yourpage/wp-login.php/ he will be redirected to the login welcome page - if however entering via s2member pro login widget - he will stay on the previous page.

If you set no login welcome page - you have to change the “my account” link in the login widget to a site where you actually show the member information. %%automatic%% will not redirect the user anywhere with no login welcome page set.

Hi Clavaque,

Sorry I am getting back to you so late. I have it set to a blank page and it redirects me back to the home page no matter where I am at on the website. I would just like my theme’s default redirect where it redirects them to the page they left off on after being redirected to the login page. Is this possible at all?

Thanks and regards,

Josh

So with the Login Welcome Page not set, s2Member affects the login redirection?

If you disable s2Member for a quick test, does the login redirection change?

Yes it does. I disabled s2Member and logged in on a specific page then ended up back on that same page after logging in. After reactivating the plugin, I tried that same thing on the same page and got redirected to the home page.

Okay. Thanks for testing that.

Can I take a look at your site? Would be possible to have access to the backend too? You can message me clicking on my name and then the blue “Message” button.

Thanks :slight_smile:

1 Like

Thanks for the login. I couldn’t see the backend, but could see the login redireciton behavior.

I see that the login link at the top is just a plain link to wp-login.php. This won’t redirect back to the page where the visitor was when he clicked the login link.

Then I looked around and a blog post at the bottom says you have to be logged in to comment. That link to wp-login.php includes the redirect_to parameter. After login, I got sent back to the previous page as expected.

I don’t know how you find that s2 affects the behavior, I couldn’t see the with and without behavior, but just from looking at the links, I can tell you the above, and the one with redirect_to does what you want.

This is not an s2Member thing, s2 doesn’t alter that redirect_to when it’s set. You just seem to be missing the redirect_to in the header link to login.

:slight_smile:

Hi Christian,

Thank you for testing that out for me, you are much appreciated! The login at the top does redirect you to the same page you left off on ONLY when the s2Member plugin is deactivated. My theme developers have the login redirect behave in that way. I did replicate that login redirect when clicking the login link at the bottom of a post just as you found.

With that being said, I will explain how I linked the log in issue with s2Member, which we are purchasing today, actually. For the below test I am using a different browser. Here is what I am doing:

  1. With the s2Member plugin deactivated, the login redirect works.
  2. If I am logged out while on any page (plugin deactivated still), then I log in, I will always be redirected to that same page after successfully logging in. This works with any page, post, and forum/topic.
  3. Now, with the s2Member plugin activated (the welcome page is disabled), the login redirect does not work.
  4. Whatever page, post, and/or forum/topic I am on (plugin activated still), it will always redirect me to the Activity page (homepage), except, of course, the log in link at the bottom of any post.

On a side note, we just want to point out that your membership plugin is the most versatile membership plugin out there. We love it and thank you all for your hard work. It was a serious struggle to find a membership plugin that was competent in what we wanted to accomplish.

If you need any further access, whether it is the cPanel, just let me know.

Thanks and regards,

Josh

Thank you very much, Josh! You made my day! :smiley:

I’m very glad you like it so much. I hope it helps you achieve all you want. And look forward to the improvements in future releases.

About the behavior you mention, I’d need to see it to be able to say more. Does the redirect_to get added to the login link when s2 is deactivated? It’d be strange, because s2 would not change any of those links… Or does your theme do/set the redirection in a non-standard way?

No, we thank you. Where would be the best place to give you guys a review?

My apologies, I am not sure where to look for that redirect_to? If you’d like, you have my permission to deactivate and reactivate the s2Member plugin in order to see if your plugin is changing any of those links.

Also, I contacted my theme developers about this issue in great detail. I am just waiting to hear back from them.

1 Like

Here, please. https://wordpress.org/support/plugin/s2member/reviews/?filter=5#new-post

I can’t, I tried viewing the WP Dashboard with the login you sent me, but it redirects me to the Home page.

You just click on the Sign In link in the header and then in the wp-login.php page, in the address see if there’s a redirect_to address at the end. You can do the same with the comments login link, so you see what it looks like.

:slight_smile:

Hi Christian,

After talking with my theme developers I ran a few tests and came up with a conclusion. My theme’s Technical Support told me the following after they ran some tests:

"We have tested your website and indeed it is redirecting to the activity page after login.
But our theme default doesn’t work that way. If it’s not s2 plugin that is causing the issue, then there are definitely other plugins.

We have also checked your child theme’s functions and it seems that the function added there doesn’t affect the redirection as well.

The only way to check this now is to do a plugin testing."

  1. The first test I did was to deactivate the s2Member plugin then hovered over the “Sign in” in the menu and it never showed the redirect_to address. The URL that showed up when hovering did not change for either the sign-in at the bottom of all posts or the sign in the menu bar. So I went to log in on a specific page with the menu “Sign in” (with the plugin still deactivated) and it redirected me to that same page I was on, even though it did not show the redirect_to address. I did this with several different pages and got the same result; I was always redirected to the same place I left off on.

  2. The second test I had to do was deactivate every plugin besides the s2Member plugin and my theme’s framework plugin, of course. I found that there were no conflicting plugins because I would log into different pages and posts and I would still get redirected to the homepage instead of the page I left off on.

  3. I also deactivated every plugin besides s2Member and it still redirected me to the homepage. The only places it redirects me to the same URL are posts with that login link at the bottom of each post.

I have concluded that the s2Member plugin does change my theme’s login-redirect behavior. Why do you think this is? Where do we go from here to stop this?

Thanks and regards,

Josh

Also, you have access to the dashboard now. For some reason the previous settings did not change!

Sorry, one more thing. After the WordPress 5.3 update the login for my website has some sort of icon shown in the screenshot. http://prntscr.com/pw4wev

My host has declared that there is no error on the server side so they advised that I contact you guys.

Thanks for the update.

hovered over the “Sign in” in the menu and it never showed the redirect_to address. The URL that showed up when hovering did not change for either the sign-in at the bottom of all posts or the sign in the menu bar

Could you ask your theme developer how they set the redirection then if they’re not using the standard redirect_to in the URL? Whatever they’re using, seems to be getting lost when s2Member is active, according to your test.

Sorry, one more thing. After the WordPress 5.3 update the login for my website has some sort of icon shown in the screenshot.

That is the eye icon from the dashicons font. It seems that font set in s2’s login design options is overriding it. Thanks for catching it, I’ll see how to improve it in the next release.

:slight_smile:

1 Like

I just asked them. Hopefully we can get it resolved!

My memory serves me well, I thought that was the eye icon. Also, v1 for the security badge just shows up as a blank but clickable space. This was only done after the update as well. Thought that would be of interest to you! If you would like me to create a new topic regarding separate issues just let me know!

No need for a separate topic. I made a note about it. Thanks. :slight_smile:

1 Like

Awesome. Also, they fixed the issue! Thank you for your help. Hope you have a great weekend.

1 Like

Wonderful! Thanks for the update! :slight_smile: