HI,
I have UsersWP and GeoDirectory – I have the default ‘subscriber’ role redirect to the profile page on login as configured in UsersWP settings.
I have another role ‘parent’ which I want to redirect to another URL on the site.
I have tried code…
add_filter( 'login_redirect', 'tr_parent_login_redirect', 1, 3 );
/**
* Redirect user after successful login.
*
* @param string $redirect_to URL to redirect to.
* @param string $request URL the user is coming from.
* @param object $user Logged user's data.
* @return string
*/
function tr_parent_login_redirect( $redirect_to, $request, $user ){
//is there a user to check?
if ( isset( $user->roles ) && is_array( $user->roles ) ) {
//check for admins
if ( in_array( 'parent', $user->roles ) ) {
$redirect_to = '/tutors/'; // Your redirect URL
}
}
And also tried the Peters Redirect Plugin but both fail and the ‘parent’ role is redirected to the same as the ‘subscriber’ role profile page.
How can I get around this?