Hi all,
I can easely retrieve user name, by user field type
$userID = (int)get_field('utente');
$theuser = get_userdata($userID);
echo 'name: ' . $theuser->user_login;
My goal is to use this function to redirect a non admin user to a specific page after the login, where the url is mysite.com/username
putting this function in function.php should be
function my_login_redirect() {
$userID = (int)get_field('utente');
$theuser = get_userdata($userID);
if ( isset( $user->roles ) && is_array( $user->roles ) ) {
if ( in_array( 'administrator', $user->roles ) ) {
return $redirect_to;
} else {
return home_url($theuser->user_login);
}
} else {
return $redirect_to;
}
}
add_filter( 'login_redirect', 'my_login_redirect', 10, 3 );
but after login the user is redirectet to profile page…
Any ideas?
Thanks a lot!