Created
November 20, 2013 17:27
-
-
Save TimBHowe/7567304 to your computer and use it in GitHub Desktop.
Redirect non admin users to the home page after logging in. - Original Source (http://tommcfarlin.com/redirect-non-admin/)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Redirect non-admins to the homepage after logging into the site. | |
function nonadmin_login_redirect( $redirect_to, $request, $user ) { | |
return ( is_array( $user->roles ) && in_array( 'administrator', $user->roles ) ) ? admin_url() : site_url(); | |
} | |
add_filter( 'login_redirect', 'nonadmin_login_redirect', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment