admin管理员组文章数量:1434960
I need help how to hide custom product data tabs (created by plugins) for custom user role on product page editor (see image).
I think it suppose to be done by modifying its CSS and apply it on functions.php
Already try and play with the below code and add the element in it, but not working.
// Remove Product Data Tabs Options on product page editor
add_filter('woocommerce_product_data_tabs' , 'hide_wc_product_tabs' );
function hide_wc_product_tabs($tabs) {
if (!current_user_can('yith_vendor')) { // replace role ID with your own
return $tabs;
}
//what code should I implement here
return $tabs;
}
Any help appreciate. thank you
I need help how to hide custom product data tabs (created by plugins) for custom user role on product page editor (see image).
I think it suppose to be done by modifying its CSS and apply it on functions.php
Already try and play with the below code and add the element in it, but not working.
// Remove Product Data Tabs Options on product page editor
add_filter('woocommerce_product_data_tabs' , 'hide_wc_product_tabs' );
function hide_wc_product_tabs($tabs) {
if (!current_user_can('yith_vendor')) { // replace role ID with your own
return $tabs;
}
//what code should I implement here
return $tabs;
}
Any help appreciate. thank you
Share Improve this question asked Apr 2, 2019 at 8:56 jasawebjasaweb 519 bronze badges 4- Which plugin is used for custom product data tabs? So I can clearly understand and will help you. – Tanmay Patel Commented Apr 2, 2019 at 9:17
- what @Karun said below solved the problem but not all, the tab created by plugin should be hide is Epeken and the additional extra tab created by the theme. – jasaweb Commented Apr 2, 2019 at 9:27
- Can you please let me know theme name or give me website URL. So I can check it. – Tanmay Patel Commented Apr 2, 2019 at 9:35
- Here is the theme link themeforest/item/… – jasaweb Commented Apr 2, 2019 at 11:00
2 Answers
Reset to default 1So using your code as reference, you could do something like:
function hide_wc_product_tabs( $tabs ) {
if ( ! current_user_can( 'yith_vendor' ) ) {
return $tabs;
}
unset( $tabs['inventory'] ); // Removes the inventory tab.
return $tabs;
}
add_filter( 'woocommerce_product_data_tabs' , 'hide_wc_product_tabs' );
These are the default WooCommerce product tabs:
Array ( [0] => general [1] => inventory [2] => shipping [3] => linked_product [4] => attribute [5] => variations [6] => advanced )
Hope it helps!
The $tabs
will return an array. Before the line return $tabs;
you should check the key in the array and unset it. You can use var_dump
to check what the array contains if you're unsure of the key name.
本文标签: Hide tabs on woocommerce product editor for user role
版权声明:本文标题:Hide tabs on woocommerce product editor for user role 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745636447a2667587.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论