This isn’t specific to Storefront or any theme really as they don’t handle role assignments. That said the following piece of code should get the job done
function custom_login_screen_detect() {
return false !== stripos( wp_login_url(), $_SERVER['SCRIPT_NAME'] );
}
$login_url = custom_login_screen_detect();
$current_user = wp_get_current_user();
if ( in_array( 'vendor', (array) $current_user->roles ) && $login_url != false ) {
wp_redirect( site_url() . '/test' );
exit;
}
Regarding customization, you’ll need to 'vendor'
over into whatever role you’ve set, make sure to keep it surrounded by the ‘
For the URL to redirect to, just modify /test
to whatever URL you want them to be redirected to. However, you can’t use /dashboard as you mentioned as that is an admin location URL set here:
https://developer.wordpress.org/reference/functions/wp_redirect_admin_locations/
So you may have to use something like /controlpanel
or similar
Thank you for your detailed response. I have implemented the following code and this seems to work as intended:
add_shortcode(‘woocommerce_my_account_custom’,’woocommerce_my_account_custom’);
function woocommerce_my_account_custom(){
if (!is_user_logged_in()) return do_shortcode(‘[woocommerce_my_account]’);
else {
$custompage=wp_redirect( site_url() . ‘/dashboard’ );//different page ID which contains custom data for logged in users
echo apply_filters(‘the_content’,$custompage->post_content);
}
}