Have you tried s2Member -> General Options -> Login Welcome Page and setting a Special Redirection URL?
Thank for your answer @kts915 !
That’s half solved the problem. The users now are redirected in the right URL.
But there is one more question. “OA social login” allows to select landing page after login. Etc, if I login from login/register pager I will end up in “Thank you” page. If I login via widget which is place somewhere else in site (etc. event page), I would like user to come back to the same page he was before, but not to be redirected to “Thank you” page.
I see login redirect files in includes/classes
There are two of them: login-redirects-r.inc.php and login-redirects.inc.php
Which one should I edit in order to achieve different redirection landing page, depending from the page, where user logged in?
If you want stable work, don’t edit plugin’s files – next update will delete your changes, and will put your site in a great mess.
Instead, use s2M conditions or mu-plugins/s2-hacks.php to create behawiour you need. There always is a way…
I wouldn’t edit the plugin’s files, because they’ll get overwritten every time you update.
The easiest way to accomplish what you are looking for would be to upgrade to the Pro version, which comes with its own login widget which you could use instead of what you’re using now. Then you can configure it according to this page: http://s2member.com/kb-article/pro-login-widget/
I think you’d just need to use %%previous%% to get what you want.
Does this “Pro login widget” works with social accounts – LinkedIn, Facebook and others or it’s only simple login form?
I don’t know. I’ve never tried.
I know that editing plugin files is not good idea, but I see no choice.
At the beginning I unselected login welcome page and left it blank in
s2Member -> General Options -> Login Welcome Page
Then I edited includes/classes/login-redirects.inc.php file.
In about line 106 this is the option, that if the page is not selected, it will redirect in home url else $redirect = home_url('/'); // Default to the home page.
I comment it and add some text below to test if it’s working and it worked
else {
$uid = 2472;
if ($uid === 2472){
$redirect = 'http://mydomain.com/events/';
}
else {
$redirect = 'http://mydomain.com/thank-you-for-joining/';
}
}
What I want to achieve is to redirect to different location depending from the page user is on. The code below is not working, it skips is_page and goes straight to 2nd else. Any ideas how could I fix it?
else {
global $page;
if (is_page('login')){
$redirect = 'http://mydomain.com/events/';
}
else {
$redirect = 'http://mydomain.com/thank-you-for-joining/';
}
}
As all go to Home page after login (initially set), I would put some logic in header.php of my child theme to do redirects when and where I need…
@krumch do you say that I shouldn’t edit includes/classes/login-redirects.inc.php at all but instead edit my header file? After login user will be redirected to home page and then I will check from which page he came and depending from page he came from I will redirect him again accordingly to events of thank you page?
Exactly 🙂
Note that there is more possible events with header.php file, so must check well… But saves from constantly changes of the same files after each update, and connected problems with the site.
Thank you for your answer!
I think I could do this with cookies too.
Well, this problem was nicely solved using cookies.
I set cookies for my pages (login and events) and then after login when user is redirected to home page I check which cookie is which and depend from the cookie redirect user where I want.
Thank you for everybody help 🙂