0

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.enter image description here

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.