Skip to content

Instantly share code, notes, and snippets.

@mateusneves
Last active June 28, 2017 13:21
Show Gist options
  • Save mateusneves/21ff3addce9fa971757597ea25e93249 to your computer and use it in GitHub Desktop.
Save mateusneves/21ff3addce9fa971757597ea25e93249 to your computer and use it in GitHub Desktop.
Redirect after Login
function redirect_users_by_role($redirect_to, $request, $user) {
return ( is_array( $user->roles ) && in_array( 'administrator', $user->roles ) ) ? admin_url() : home_url();
} // cm_redirect_users_by_role
add_action( 'login_redirect', 'redirect_users_by_role', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment