WordPress Multisite: Redirects users after login to the site’s admin dashboard
-
I want to let the users log in through the main site(www.example.com/wp-admin), Once the user successfully logged In, I want to redirect them to the site admin(ie: https://www.example1.com/wp-admin/index.php)they belong to. I tried different ways to achieve this but none of them is working so far. Here is the way I do.
//fetch the user' site id and redirect to the site. $user_blogs = get_blogs_of_user($userID); if (!empty($user_blogs)) { $siteInfo = array(); foreach ($user_blogs as $site_id => $site_values) { $siteInfo[] = $site_values->siteurl; } $user_site = $siteInfo[0]; $redirect_url = $siteInfo[0]."/wp-admin" ; } //set the cookies wp_set_auth_cookie($user->ID, true, false); //override the cookie domain define('COOKIE_DOMAIN', $user_site); define('COOKIEPATH', '/'); define('COOKIEHASH', md5($user_site)); //redirect users to their site admin dashboard. wp_safe_redirect( $redirect_url ); exit;
Let me know if it is possible?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘WordPress Multisite: Redirects users after login to the site’s admin dashboard’ is closed to new replies.