Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thread Starter rohan066

    (@rohan066)

    @gausulazam, Thank you for your reply. I have solved the issue using this snippet.

    //woocommerce user dashboard customization
    function my_account_custom_design(){
        echo do_shortcode('[INSERT_ELEMENTOR id="1146"]');
    }
    
    add_action('woocommerce_account_dashboard','my_account_custom_design');
    
    function custom_user_redirect() {
        if ( is_user_logged_in() ) {
            $user = wp_get_current_user();
            
             // Check if user is logged in and trying to access wp-admin
        if (strpos($_SERVER['REQUEST_URI'], 'wp-admin') !== false && !current_user_can('administrator') && in_array( 'seller', (array) $user->roles )) {
            // Redirect users with roles other than administrator
            wp_redirect(home_url('/seller-account/')); // Redirect to home page or any other URL
            exit();
        }
        
        if (strpos($_SERVER['REQUEST_URI'], 'wp-admin') !== false && !current_user_can('administrator') && in_array( 'customer', (array) $user->roles )) {
            // Redirect users with roles other than administrator
            wp_redirect(home_url('/my-account/')); // Redirect to home page or any other URL
            exit();
        }
            
          
        }
    }
    
    add_action( 'init', 'custom_user_redirect' );
Viewing 1 replies (of 1 total)