You could hook to the get_terms_args
filter conditionally depending on your user/role
Something along those lines
add_filter( 'get_terms_args', 'restrict_cat', 10, 2 );
function restrict_cat( $args, $taxonomies ){
// Don't run if we are not dealing with categories
if( 'category' != $taxonomies[0] )
return $args;
// The check for the user we want to restrict
// you could use current_user_can( $capability ) or test for a specific role here
if( 1 == get_current_user_id() ){
$args['exclude'] = array(
'cat_id1',
'cat_id2'
);
return $args;
}
return $args;
}
check out https://developer.wordpress.org/reference/functions/get_terms/ for a list of available args.
Related Posts:
- Filtering by Category doesnt paginate correctly on the backend
- How to Change the Categories Order in the Admin Dashboard?
- Filter categories using tags
- Make parent categories not selectable
- Add custom category name as data-filter to switch between these categories
- Remove Categories and Tags from Admin Dashboard
- Can paginate_links() be customized for a specific category or tag?
- Dropdown category filter
- Make parent category not selectable when it has child categories
- Replace category titles
- Hide posts of a certain category unless logged in
- What’s the Simplest Way to Override/Rewrite the %category% Permalink Structure Tag?
- Custom order categories in admin dashboard
- How to Filter categories in the permalink structure
- How to display posts under a specific subcategory of a given category
- Taxonomy filter all children
- Filter Home Page Posts in Buddypress [closed]
- Categorising posts/pages into years published
- Inserting Category programmatically
- Automatically set default password to all posts in a specific category
- get_the_categories filter returns an empty array
- category filter doesn’t work in WPML
- Query posts from category based on a filter most favorited
- Filter Categories in meta box for CPTs
- Show only first category name in RSS?
- How to organize custom categories for filtering and selecting
- Filter $cpt categories to omit certain category
- How to set a filter by category within a customised page
- Refine/Filter the Search Results by Category
- Admin comments and user restrictions
- WordPress Post # of # filtered by category slug
- Pagination for ajax category filter
- ajax for filtering posts by category in wordpress loops
- How to hide category name
- How to insert category list into post creation page, and retrieve chosen categories?
- How to make the ‘delete’ button inactive on some categories?
- Overriding default calendar to show posts from a category
- How can I display tags as categories?
- Display all product tags associated with a specific product category
- Filter WooCommerce archive pages by an additional category
- Portfolio Filter Buttons Wont Work
- “Virtual category page” based on a custom field filter
- Custom tax_query filter not working for Woocommerce product categories
- Edit tag_id in category pages of dashboard
- Change post title if post has specific category
- Filter By Category Dropdown List With Custom Taxonomies
- How can I filter posts by tag on the fly
- Change Default Content when Creating a Post based on Previous Category Choice
- Maintaining a separate posts page for certain categories and don’t show those on home page
- Exclude posts without category from loop
- How to filter post from categories only if the posts appears in one of them, not the other?
- How to fix select filter on category
- wp_dropdown_categories() works correctly but the list is not filtered in admin for custom post type. What is the problem?
- Add $args to wp_list_categories
- How to hide a category or tag everywhere EXCEPT for use with get_posts
- Page category filter in admin dashboard
- Add filter for specific category only
- How to create category filter on a blog like on the site below?
- How to filter tags by category?
- Custom Taxonomy Isotope Grid – Filter Buttons Not Working
- How to exclude a category returned by get_categories from function.php?
- Can’t display posts by filtering categories using isotope.js
- Correct Hook/Filter to amend category choices on post edit page
- Restrict retrieved terms by category?
- Hiding by default posts in given category except for some cases
- Remove “Category:”
- ACF Gallery with Media Categories – how do display categories and sort
- Custom filters inside a specific category?
- filter single_cat_title avoiding the breadcrumbs
- How can I add a Categories page link to a menu? [closed]
- Right way for setting categories
- Custom built theme won’t filter categories
- category filter doesn’t work
- How to create a photo gallery that can be filtered by the image categories
- Remove “?category=” in the URL wordpress ajax filter work for category
- Replace category titles inside RSS feed
- Error while add Category or Tag in WordPress
- how to remove alphabetical order of category in WordPress?
- excude a specidic category from showing in the “relative posts”
- get_object_term_cache duplicate terms after update to wordpress 6
- How to use category slug with a regular page
- Show posts from a single category by default using wordpress.com
- WordPress PageNavi Plugin not working in category.php
- Category post count is not correct
- Display all categories but only if they have posts in them that have a specific tag assigned
- Sort posts by child category name
- 404 on category URL
- Disable Category Taxonomy
- Intermittent Gutenberg 504 Gateway Timeout when calling REST route to retrieve categories
- Duplicate new categories across multisite network
- display specific category when website loads
- Filter sub-category from checkbox form
- Excluding current category from sidebar’s post widget, elementor, query-id
- How do you get sticky posts to work with categories?
- Migrate the posts of a category to another blog as a custom taxonomy
- Woocommerce only display child category when parent is checked (on add new product page)
- Include last post date in get_categories loop
- get list of category from a specific post with get_term()
- How to exclude certain categories showing in Gutenberg?
- Categories not posts at the frontpage