Disable categories and their listings on results page

I am a new subscriber of all Extensions bundle.
Based on the user role, I would like to hide some categories and their related listings from :
1 - the results page (listings)
2 - the filter (e.g some chosen categories would be available only for given user role)
3 - listing-categories blocks
How can I do this with snippets ?
Many thanks for your help


Sorry, there’s no simple code snippet for this, it would require a custom implementation. If customizations beyond the available features are required for your site, please consider hiring someone for custom work: https://fvrr.co/32e7LvY

Hi Andrii,
Thank you for your quick answer.
But it seems that my point 2 has a simple solution that could be similar to the below :

	    $disabled_categories_ids = [1,2,3];
		foreach($disabled_categories_ids as $category){
		return $form; 
		// Get user.
		$user = get_userdata(get_current_user_id());
		if(!in_array('[the_role_you_want]', $user->roles)){
		foreach($disabled_categories_ids as $category){
		return $form;

For points 1 and 3, could you please give me a few development guidances, even if I understand that you can not help me in details ?

Many thanks

I’m sorry for the delay. Please provide more details, do you mean hiding categories from selection (radio buttons), or hiding listings from the search results based on their category?

I found a solution for hiding categories from selection (radio buttons). See my previous post above…
But I am still looking for a solution for hiding listings from the search results based on their category.
I am seeking to show some listings results (scope A) to my users and at the same time restrict some listings from categories directly based on the user role (scope B). Eg : People with a given role should be able to see more results including restricted categories (Scope A + Scope B).
I would be happy if you could just give me some guidances (which files or parts to alter).
Thank you :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.