I’ve this code in my wordpress customized plugin
<?php
public perform role_login_redirect()
{
$redirect_to;
$consumer = wp_get_current_user();
if( isset($user->roles) && is_array($user->roles) && in_array('vendor', $user->roles) ){
$redirect_to = site_url('/customers-manage');
wp_safe_redirect( $redirect_to );
exit;
} elseif( isset($user->roles) && is_array($user->roles) && in_array('buyer', $user->roles) ){
$usermeta = get_user_meta( $user->ID );
if( $usermeta['account_status'][0] === 'pending' || $usermeta['account_status'][0] === 'rejected' ){
$redirect_to = site_url('/account-error');
wp_safe_redirect( $redirect_to );
exit;
} else {
$redirect_to = site_url('/user-profile');
wp_safe_redirect( $redirect_to );
exit;
}
}
return $redirect_to;
}
add_filter('login_redirect', array($this, 'role_login_redirect'));
I am attempting to redirect the customers after they login primarily based on the position and on some consumer meta . I am going through the problem that the customers can be redirected after login to the default wordpress profile dashboard web page, this happen with the seller position and in addition with buyer position. Is there one thing unsuitable within the code and the way I can forestall customers from displaying the default wordpress dashboard accurately??