1

I am novice trying to use the following code:

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 );

However, in this example the author is checking to see if users have a specific meta value and returning them to the same url if they do.

I would like to use the actual user meta value for example user-meta "url" value "example1" So that each user is redirected to to a different page based on their meta value.

Please can someone show me how I would go about doing this.

Thank you!

  • 3
    have you tried $url = get_user_meta( $user->ID, 'url', true) ? – mmm Jun 26 '16 at 19:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.