Hey Brajesh!
Hope you’re doing well.I wanted to get some advise/help on a specific issue I’m dealing with.
I’ve created a network of sites that share the user and user_meta tables but are separate installs. I’ve set up a common session cookie so that the sites have a single sign on environment. What I am stuck on is how to redirect all login/registration request to a specific domain and have them redirected back to the domain where they came from.
Example:
If a user logs in from Site B – they are taken to the login.mydomain.com subdomain. They sign in – when they are authenticated they are then returned back to Site B.Same for Registrations
Is there some code I can use in the functions.php file for the login.mydomain.com or subdomain.mydomain.com to get this to work properly?
Thanks for your help.
PS – I am willing to pay for this one.
Hi Joshua,
Welcome back.For login, It should be fairly easy to do with some custom code.
For registration, I am not sure how your current registration works. Do you need activation for the accounts? We will need to find some way to validate the referrer(is from your network of sites) and store it to redirect later.
I will post the code when I am back to work today.
Thank you
BrajeshHi,
You may want to put a code like this in a plugin and network activateadd_filter( 'login_url', function ( $login_url, $redirect, $force_reauth ) { $login_url = 'https://login.tidesofwar.net'; $redirect = site_url( $_SERVER['REQUEST_URI'] ); $login_url = add_query_arg( 'redirect_to', urlencode( $redirect ), $login_url ); if ( $force_reauth ) { $login_url = add_query_arg( 'reauth', '1', $login_url ); } return $login_url; }, 3 );
I haven’t tested it but this or slightly modified version of it should work for login.
Please let me know how it goes.
Regards
BrajeshHi Joshua,
Please make sure you have not copied for the notification mail and have copied it form the above reply.The code in notification mail gets entity encoded and will cause issue.
Also, if you copy from above and it is still causing issue, Please check error log and post me.
Thank you
Brajesh
You must be logged in to reply to this topic.