Created
May 24, 2013 01:02
-
-
Save jaredatch/5640656 to your computer and use it in GitHub Desktop.
Redirect users with a certain role to a specific page 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 with 'foo' role to a specific page after login | |
* | |
* @since 1.0.0 | |
*/ | |
function ja_role_login_redirect( $redirect_to, $request, $user ){ | |
//is there a user to check? | |
if ( isset( $user->roles ) && is_array( $user->roles ) ) { | |
if( in_array( 'foo', $user->roles ) ) { | |
return site_url( 'foo-page' ); | |
} else { | |
return $redirect_to; | |
} | |
} | |
else { | |
return $redirect_to; | |
} | |
} | |
add_filter( 'login_redirect', 'ja_role_login_redirect', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment