Last active
October 22, 2015 08:54
-
-
Save kevinwhoffman/ed6f3656d2795928c3fe to your computer and use it in GitHub Desktop.
WP Redirect Users After Login
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
<?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