Christina
Christina

Reputation: 34642

How to Enable the WordPress Toolbar Bar with WC Vendors and WooCommerce

When you use WC Vendors your vendor gets a profile page which has the standard checkbox where they can choose to show the toolbar, but it doesn't work on the front end. How do you allow vendors to see this handy toolbar when viewing the site?

You can use the woocommerce_disable_admin_bar as follows but this shows the toolbar to your store customers too, which I don't want.

add_filter( 'woocommerce_disable_admin_bar', '__return_false' );

Upvotes: 1

Views: 250

Answers (1)

Christina
Christina

Reputation: 34642

First find out what a vendor can do with 'current_user_can'. Then conditionally remove the main filter 'show_admin_bar'.

Make a child theme if you are not using one or a functions plugin. I recommend WPClips.

/** 
 *
 * Show Admin Bar/Toolbar front end to Vendors 
 *
 */
function childthemeprefix_show_toolbar_vendors() { 

    if ( current_user_can( 'manage_product' ) ) {

        remove_filter( 'show_admin_bar', 'wc_disable_admin_bar', 10, 1 );

    }

}
add_action( 'after_setup_theme', 'childthemeprefix_show_toolbar_vendors' );

Upvotes: 2

Related Questions