Remove/hide the navigation links above the woo-commerce products table for a specific user

人盡茶涼 提交于 2019-12-11 17:45:01

问题


I have placed a filter in the functions.php file on my WordPress website to filter products based on the role (advertiser) assigned to currently logged in user. When I log in to my site from an advertiser account, I am able to view, edit or delete only those products which I have created using the following code:

add_action( 'pre_get_posts', 'show_specific_advertiser_products' );
function show_specific_advertiser_products( $query ) {
    $user = wp_get_current_user();
    if ( is_admin() && $query->get( 'post_type') === 'product' && in_array('administrator', $user->roles) ) {
        $query->set( 'author', $user->ID );
    }
}

But, now I want to hide/disable the following navigation links which appear above the table.

Because, when I click on the All Products sidebar element, I am able to view only those products which are related to me. However, when I click on any of the navigation link above the table, such as All, Published, Drafts, Trash etc, then I am still able to view all products regardless of a user and his/her role.

I simply want these links to be hidden/disable for advertiser role. I simply need some reference to a filter which can remove these links like we use remove_menu_page( 'edit.php?post_type=page' ); for removing sidebar elements for a user.

来源:https://stackoverflow.com/questions/54891028/remove-hide-the-navigation-links-above-the-woo-commerce-products-table-for-a-spe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!