Skip to content

Instantly share code, notes, and snippets.

@TimBHowe
Created November 20, 2013 17:27
Show Gist options
  • Save TimBHowe/7567304 to your computer and use it in GitHub Desktop.
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/)
// 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