简体   繁体   English

如何通过WC供应商和WooCommerce启用WordPress工具栏

[英]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. 当您使用WC Vendors时,您的供应商会获得一个配置文件页面,该页面具有标准复选框,他们可以在其中选择显示工具栏,但不适用于前端。 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. 您可以按以下方式使用woocommerce_disable_admin_bar ,但这也向商店客户显示了工具栏,我不希望这样做。

add_filter( 'woocommerce_disable_admin_bar', '__return_false' );

First find out what a vendor can do with 'current_user_can'. 首先找出供应商可以使用“ current_user_can”做什么。 Then conditionally remove the main filter 'show_admin_bar'. 然后有条件地删除主过滤器“ show_admin_bar”。

Make a child theme if you are not using one or a functions plugin. 如果您不使用一个或一个功能插件,请创建一个子主题。 I recommend WPClips . 我推荐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' );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM