Skip to content

Instantly share code, notes, and snippets.

@sjaved87
Created March 24, 2016 14:37
Show Gist options
  • Save sjaved87/d1c96c8a8ca033ece106 to your computer and use it in GitHub Desktop.
Save sjaved87/d1c96c8a8ca033ece106 to your computer and use it in GitHub Desktop.
This code snippet will detect the user's site automatically on login and redirect to respective site after login. For WordPress MultiSite only.
<?php
function go_to_primary_blog($redirect_to, $request, $user){
$user_info = get_userdata($user->ID);
return get_blogaddress_by_id($user_info->primary_blog) . 'wp-admin';
}
add_filter("login_redirect", "go_to_primary_blog", 999, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment