the vendor should redirected to the (home_url)/dashboard instead of home page
-
I’m building a multivendor woocommerce WordPress website using the Dokan plugin.
When logged-in users want to access (home_url)/wp-admin.
Admins get redirected to the wp-dashboard, customers get redirected to woocommerce my account page and a vendor gets redirected to the home page. I want the vendor to get redirected to the page (home_url)/dashboard instead of the home page.
To solve this, I used this code snippet in function.php/** * Custom redirection for different user roles. */ function custom_user_redirect() { if ( is_user_logged_in() ) { $user = wp_get_current_user(); if ( in_array( 'administrator', (array) $user->roles ) ) { // Redirect administrators to wp-dashboard. wp_redirect( home_url( '/wp-admin/' ) ); exit(); } elseif ( in_array( 'customer', (array) $user->roles ) ) { // Redirect customers to the WooCommerce My Account page. wp_redirect( home_url( '/my-account/' ) ); exit(); } elseif ( in_array( 'vendor', (array) $user->roles ) ) { // Redirect vendors to the custom dashboard page. wp_redirect( home_url( '/dashboard/' ) ); exit(); } } } add_action( 'login_redirect', 'custom_user_redirect' );
but still, vendors are getting redirected to the home page instead of redirecting ( home_url( ‘/dashboard/’ ). how to solve this issue?
- The topic ‘the vendor should redirected to the (home_url)/dashboard instead of home page’ is closed to new replies.