// Here is the redirect admins to dashboard
function wc_custom_user_redirect( $redirect, $user ) {
$role = $user->roles[0];
$dashboard = admin_url();
$myaccount = get_permalink( wc_get_page_id( 'myaccount' ) );
if( $role == 'administrator' ) {
$redirect = $dashboard;
} elseif ( $role == 'shop-manager' ) {
$redirect = $dashboard;
} elseif ( $role == 'editor' ) {
$redirect = $dashboard;
} elseif ( $role == 'author' ) {
$redirect = $dashboard;
} elseif ( $role == 'customer' || $role == 'subscriber' ) {
$redirect = $myaccount;
} else {
$redirect = $myaccount;
}
return $redirect;
}
add_filter( 'woocommerce_login_redirect', 'wc_custom_user_redirect', 10, 2 );
function wc_custom_user_redirect( $redirect, $user ) {
$role = $user->roles[0];
$dashboard = admin_url();
$myaccount = get_permalink( wc_get_page_id( 'myaccount' ) );
if( $role == 'administrator' ) {
$redirect = $dashboard;
} elseif ( $role == 'shop-manager' ) {
$redirect = $dashboard;
} elseif ( $role == 'editor' ) {
$redirect = $dashboard;
} elseif ( $role == 'author' ) {
$redirect = $dashboard;
} elseif ( $role == 'customer' || $role == 'subscriber' ) {
$redirect = $myaccount;
} else {
$redirect = $myaccount;
}
return $redirect;
}
add_filter( 'woocommerce_login_redirect', 'wc_custom_user_redirect', 10, 2 );
No comments:
Post a Comment