It works if I login via the normal WP login form but if I login with social media, it doesn't work. How can I redirect the user to correct landing page according to his custom role no matter he logins via WP login form or social media. I use the plugin Login with Google as the social login.
I imagine there might be two things going on here.
Possibly the social login plugin also uses the login_redirect filter, but its code is running after your custom code and overwriting the changes that you make to the $redirect_to url.
In which case you can add a higher priority number to your add_filter call so that the code runs later. To be sure your code runs last, you could change that line to:
If that doesn't work then it would suggest that the social login plugin bypasses the normal code so that the login_redirect filter (which is a core WordPress filter) doesn't get run at all.
If that is the case you'll need to ask the social login plugin authors for help. You can explain to them that you are trying to use the login_redirect filter and it works with normal logins but not with social logins via their plugin.
The topic ‘[Closed] Auto redirect base on the user role’ is closed to new replies.