Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Redirect multi-site usert to theyr blog WordPress



I have a multi-site install setup like that

I have one super admin user that can acces all the site and then 1 user admin registred by site ---> user1admin ----> user2admin ---> user3admin ---> user4admin

What I would like to do is the following

when any of the "admin" user try to login from any site wp-admin they get logged in and redirected to their blog.

for example if user1admin login from it would get redirected to dashboard (whithout having to type his login/pass again)

or another example if user3admin try to login from it would get redirected to dashboard without having to enter his infos again.

In this multi-site install there would be no more site or user added over time.

Thanks for your help

Answers (3)


Romel Apuya answers:


I think this one should do it

function primary_login_redirect( $redirect_to, $request_redirect_to, $user )
if ($user->ID != 0) {
$user_info = get_userdata($user->ID);
if ($user_info->primary_blog) {
$primary_url = get_blogaddress_by_id($user_info->primary_blog) . 'wp-admin';
if ($primary_url) {
return $redirect_to;
add_filter('login_redirect','primary_login_redirect', 10, 3);


Arnav Joy answers:

try this and please modify the username and the redirect domain as per your need


function my_login_redirect( $redirect_to, $request, $user ) {
//is there a user to check?
global $current_user;

if( $current_user->user_login == 'user1admin' )
return '';
else if( $current_user->user_login == 'user3admin' )
return '';
return $redirect_to;


add_filter( 'login_redirect', 'my_login_redirect', 10, 3 );

l.pirondini comments:

Hi, Thanks for the answer this does redirect the user to the correct but dosen't log him in.

Arnav Joy comments:

no it will not login to other domain it is just for redirection


Luis Abarca answers:

Had you tried to add a custom field to user profile with the URL of the site, then redirect the user to that URL with [[LINK href=""]]login_redirect[[/LINK]].