Skip to content

Instantly share code, notes, and snippets.

@kevinwhoffman
Last active October 22, 2015 08:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinwhoffman/ed6f3656d2795928c3fe to your computer and use it in GitHub Desktop.
Save kevinwhoffman/ed6f3656d2795928c3fe to your computer and use it in GitHub Desktop.
WP Redirect Users After Login
<?php
/**
* Redirect users after login
*/
add_filter('login_redirect', 'vms_login_redirect', 10, 3);
function vms_login_redirect( $redirect_to, $request, $user ) {
if( !isset( $_REQUEST['redirect_to'] ) ) {
if ( current_user_can( 'manage_options' ) ) { // does not return true even for admins
return admin_url();
} else {
return home_url();
}
} else {
return $redirect_to;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment