Reply To: Log in redirect based on user role?

Home Forums User Registration Log in redirect based on user role? Reply To: Log in redirect based on user role?

#7259

LFFprop
Participant

I understand what your are advising, but it doesn’t have any effect.

I have 2 user roles: ‘author’ and ‘PayingVisitor’. so this is what I added to the functions.php for the child theme:

/** Log-in redirect based on user role */
add_filter( ‘user_registration_login_redirect’, ‘ur_login_redirect’, 10, 2 );
function ur_login_redirect( $redirect, $user ) {

$user_meta = get_userdata( $user_id );
$user_roles = $user_meta->roles;

if ( in_array( ‘author’, $user_roles ) ) {
$redirect = ‘profiel-bewerken’;
} elseif( in_array( ‘PayingVisitor’, $user_roles ) ) {
$redirect = ‘zoeken’;
}

return $redirect;
}

But still, the ‘My Account’ page appears after logging in.