# Hide categories only for a specific plan

**URL:** <https://community.hivepress.io/t/hide-categories-only-for-a-specific-plan/2330>\
**Category:** Memberships\
**Tags:** memberships\
**Created:** [October 13, 2022, 9:30pm UTC](https://community.hivepress.io/t/hide-categories-only-for-a-specific-plan/2330 "2022-10-13T21:30:50Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![arielkbs](https://community.hivepress.io/user_avatar/community.hivepress.io/arielkbs/32/2085_2.png) [@arielkbs](https://community.hivepress.io/u/arielkbs)\
**Post date:** [October 13, 2022, 9:30pm UTC](https://community.hivepress.io/t/hide-categories-only-for-a-specific-plan/2330/1 "2022-10-13T21:30:50Z")

</div>

Guys, I saw the following forum post and it met my project needs: [https://community.hivepress.io/t/hide-add-a-listing-button-only-to-specific-plan/349](https://community.hivepress.io/t/hide-add-a-listing-button-only-to-specific-plan/349)

Now I would like to hide the categories according to the plan chosen in the Membership extension. I am referring to the categories on the page /submit-listing/details/

---

<div class="post-metadata">

**Author:** ![arielkbs](https://community.hivepress.io/user_avatar/community.hivepress.io/arielkbs/32/2085_2.png) [@arielkbs](https://community.hivepress.io/u/arielkbs)\
**Post date:** [October 13, 2022, 10:54pm UTC](https://community.hivepress.io/t/hide-categories-only-for-a-specific-plan/2330/2 "2022-10-13T22:54:27Z")

</div>

Similar to what is done using the following PHP snippet

> [@Disable category selection in listing creation](https://community.hivepress.io/t/disable-category-selection-in-listing-creation/2187):
>
> Hello, We have created few categoeries, but we want to disable one category, so it wouldn’t be selectable at listing creation. Only administrator will be able to create this listing manually in wp-admin. Is it possible to hide one category from listing form?

But according to the user’s active plan.

---

<div class="post-metadata">

**Author:** ![ihor](https://community.hivepress.io/user_avatar/community.hivepress.io/ihor/32/5_2.png) [@ihor](https://community.hivepress.io/u/ihor)\
**Post date:** [October 14, 2022, 12:47pm UTC](https://community.hivepress.io/t/hide-categories-only-for-a-specific-plan/2330/4 "2022-10-14T12:47:24Z")

</div>

Hi,  
If you mean preventing adding listings to specific categories with Memebrships, untofunately there’s no such feature because Memberships don’t restrict the listing submission, it restricts viewing listings, vendors or specific details. We plan to create a single monetization extension that will include features of both Paid Listings and Memberships, it’ll probably be released as a Memberships update.

---

<div class="post-metadata">

**Author:** ![arielkbs](https://community.hivepress.io/user_avatar/community.hivepress.io/arielkbs/32/2085_2.png) [@arielkbs](https://community.hivepress.io/u/arielkbs)\
**Post date:** [October 14, 2022, 12:58pm UTC](https://community.hivepress.io/t/hide-categories-only-for-a-specific-plan/2330/5 "2022-10-14T12:58:03Z")

</div>

ihor i believe it is possible from a code similar to what yevhen solved in the topics above. If it is possible to hide the ad button according to the plan, and it is also possible to hide categories at the time of making the ad it is possible to do it by the user’s plan.

---

<div class="post-metadata">

**Author:** ![arielkbs](https://community.hivepress.io/user_avatar/community.hivepress.io/arielkbs/32/2085_2.png) [@arielkbs](https://community.hivepress.io/u/arielkbs)\
**Post date:** [October 15, 2022, 2:16pm UTC](https://community.hivepress.io/t/hide-categories-only-for-a-specific-plan/2330/8 "2022-10-15T14:16:41Z")

</div>

Yevhen see if it’s possible, I believe it’s just a mix of the two codes from the topics above.

---

<div class="post-metadata">

**Author:** ![yevhen](https://community.hivepress.io/user_avatar/community.hivepress.io/yevhen/32/23_2.png) [@yevhen](https://community.hivepress.io/u/yevhen)\
**Post date:** [October 16, 2022, 5:32pm UTC](https://community.hivepress.io/t/hide-categories-only-for-a-specific-plan/2330/10 "2022-10-16T17:32:22Z")

</div>

Please try this PHP snippet. Please change `1,2,3` on the categories id that you want to remove from the selection and please change your\_membership\_plan\_id on the membership plan id which hides these categories. Also please note that it can require further customization. If you are not familiar with code customization then please consider hiring someone for custom work [https://fvrr.co/32e7LvY](https://fvrr.co/32e7LvY)

```auto

add_filter(
	'hivepress/v1/models/listing/fields',
	function($fields){
		if(!is_user_logged_in() || !hivepress()->get_version('memberships')){
			return $fields;
		}
		
		$membership = \HivePress\Models\Membership::query()->filter(['user' => get_current_user_id()])->get_first();

        if(!$membership || your_membership_plan_id === $membership->get_plan__id()){
            $disabled_categories_ids = [1,2,3];
		
			if(isset($fields['categories']['options'])){
				foreach($disabled_categories_ids as $category_id){
					unset($fields['categories']['options'][$category_id]);
				}	
			}
        }
		
		return $fields;
	},
	10000
);

```

---

<div class="post-metadata">

**Author:** ![arielkbs](https://community.hivepress.io/user_avatar/community.hivepress.io/arielkbs/32/2085_2.png) [@arielkbs](https://community.hivepress.io/u/arielkbs)\
**Post date:** [October 17, 2022, 2:49pm UTC](https://community.hivepress.io/t/hide-categories-only-for-a-specific-plan/2330/11 "2022-10-17T14:49:28Z")

</div>

yevhen I’m your fan man! It worked perfectly, I was looking forward to this solution 🙏

---

<div class="post-metadata">

**Author:** ![system](https://community.hivepress.io/user_avatar/community.hivepress.io/system/32/13990_2.png) [@system](https://community.hivepress.io/u/system)\
**Post date:** [November 16, 2022, 2:50pm UTC](https://community.hivepress.io/t/hide-categories-only-for-a-specific-plan/2330/12 "2022-11-16T14:50:03Z")

</div>

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