Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save eyecandy91/dd09d2d3a98fc34513c252d354fa2e61 to your computer and use it in GitHub Desktop.
Save eyecandy91/dd09d2d3a98fc34513c252d354fa2e61 to your computer and use it in GitHub Desktop.
redirect back to home for user
function admin_login_redirect( $redirect_to, $request, $user ) {
global $user;
if( isset( $user->roles ) && is_array( $user->roles ) ) {
if( in_array( "administrator", $user->roles ) ) {
return $redirect_to;
}
else {
return home_url('/portal');
}
}
else {
return $redirect_to;
}
}
add_filter("login_redirect", "admin_login_redirect", 10, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment