Skip to content

Instantly share code, notes, and snippets.

@feliciaceballos
Created March 12, 2019 07:23
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save feliciaceballos/e5f7c32bbcd65d6ddf04e8ceb267c45c to your computer and use it in GitHub Desktop.
WordPress Login Page redirect to Home Page
<?php
//remove <?php when you paste inside your functions.php file
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();
}
}
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