Skip to content

Instantly share code, notes, and snippets.

@corsonr
Created August 7, 2012 08:24
Show Gist options
  • Select an option

  • Save corsonr/3283159 to your computer and use it in GitHub Desktop.

Select an option

Save corsonr/3283159 to your computer and use it in GitHub Desktop.
how to redirect a user after login
// Redirect admins to the dashboard and other users elsewhere
add_filter( 'login_redirect', 'xxx_login_redirect', 10, 3 );
function xxx_login_redirect( $redirect_to, $request, $user ) {
// Is there a user?
if ( is_array( $user->roles ) ) {
// Is it an administrator?
if ( in_array( 'administrator', $user->roles ) )
return home_url( '/wp-admin/' );
else
return home_url();
// return get_permalink( 83 );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment