Last active
November 22, 2018 17:39
-
-
Save wpscholar/4665879 to your computer and use it in GitHub Desktop.
WordPress function for redirecting users based on custom user meta
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 | |
/** | |
* WordPress function for redirecting users based on custom user meta | |
*/ | |
function my_login_redirect( $url, $request, $user ){ | |
if( $user && is_object( $user ) && is_a( $user, 'WP_User' ) ) { | |
if( 'cool' == get_user_meta( $user->ID, '_is_cool', true ) ) { | |
$url = home_url('/cool-people-only/'); | |
} | |
} | |
return $url; | |
} | |
add_filter('login_redirect', 'my_login_redirect', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment