• Resolved keith1025

    (@keith1025)


    Hi, I want to ask how to direct the vendor dashboard page to the woocommerce my account page just after the vendor logged in?

    Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @keith1025, currently when a vendor gets logged into the site, we direct them to our dashboard page.

    But, if you want to change this flow, then you have to do custom code. For this, please use this filter :
    woocommerce_login_redirect
    login_redirect

    Thread Starter keith1025

    (@keith1025)

    Like this?

    <?php
    add_filter( ‘woocommerce_login_redirect’, ‘login_redirect’, 10, 2 );

    Hi @keith1025, add this code to the function.php of the active child theme, to direct vendor to my account page, when they will log into the site :

    add_filter('login_redirect', 'wp_wcmp_vendor_login_redirect', 99, 3);
    add_filter('woocommerce_login_redirect', 'wcmp_vendor_login_redirect', 99, 2);
    function wp_wcmp_vendor_login_redirect($redirect_to, $requested_redirect_to, $user) { 
       //is there a user to check?
       if(class_exists('WCMp')){
           if (isset($user->roles) && is_array($user->roles)) {
               //check for vendor
               if (in_array('dc_vendor', $user->roles)) {
                   // redirect them to the default place
                   wp_redirect( get_permalink( get_option('woocommerce_myaccount_page_id')) );
               }
           }
       }
       return $redirect_to;
    }
    function wcmp_vendor_login_redirect($redirect_to, $user){
       if(class_exists('WCMp')){
           if (isset($user->roles) && is_array($user->roles)) {
               //check for vendor
               if (in_array('dc_vendor', $user->roles)) {
                   // redirect them to the default place
                   wp_redirect( get_permalink( get_option('woocommerce_myaccount_page_id')) );
               }
           }
       }
       return $redirect_to;
    }
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Redirect Dashboard Page’ is closed to new replies.