# Hide "Add a listing" Button only to specific Plan

**URL:** <https://community.hivepress.io/t/hide-add-a-listing-button-only-to-specific-plan/349>\
**Category:** Memberships\
**Tags:** memberships\
**Created:** [June 2, 2022, 10:50pm UTC](https://community.hivepress.io/t/hide-add-a-listing-button-only-to-specific-plan/349 "2022-06-02T22:50:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![HivePressUser](https://community.hivepress.io/user_avatar/community.hivepress.io/hivepressuser/32/99_2.png) [@HivePressUser](https://community.hivepress.io/u/HivePressUser)\
**Post date:** [June 2, 2022, 10:50pm UTC](https://community.hivepress.io/t/hide-add-a-listing-button-only-to-specific-plan/349/1 "2022-06-02T22:50:50Z")

</div>

Hi there,

I would like to hide the “Add a listing” button only to users that have selected a specific plan (membership). All my users have to select a plan prior to use the site. Then regular users (buyers) have Membership1. I have two types of vendors with Plans: Membership2 and Membership3

I would like to hide the button “Add a listing” to buyers with Membership1, but show it to vendors with Membership2 and Membership3. is that possible?

Thanks,

---

<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:** [June 3, 2022, 10:10am UTC](https://community.hivepress.io/t/hide-add-a-listing-button-only-to-specific-plan/349/2 "2022-06-03T10:10:36Z")

</div>

Please try this PHP snippet. Please just change **your\_membership\_plan\_id** with the id of **Membership1** plan

```auto
add_filter(
    'hivepress/v1/templates/site_header_block',
    function( $template ) {

    if(is_user_logged_in() && hivepress()->get_version('memberships')){
        $membership = \HivePress\Models\Membership::query()->filter(['user' => get_current_user_id()])->get_first();

        if(!$membership || your_membership_plan_id === $membership->get_plan__id()){
            $template = hivepress()->helper->merge_trees(
			$template,
			[
				'blocks' => [
					'listing_submit_link' => [
						'type' => 'content',
					],
				],
			]
		);
        }
    }

    return $template;
    },
    1000
);

```

---

<div class="post-metadata">

**Author:** ![HivePressUser](https://community.hivepress.io/user_avatar/community.hivepress.io/hivepressuser/32/99_2.png) [@HivePressUser](https://community.hivepress.io/u/HivePressUser)\
**Post date:** [June 3, 2022, 11:36pm UTC](https://community.hivepress.io/t/hide-add-a-listing-button-only-to-specific-plan/349/3 "2022-06-03T23:36:41Z")

</div>

Hi yevhen,

Thanks fo the snippet. it works partially. The button is hidden when regular user with buyer Membership1 is logged in, and it shows to vendors once they have logged in. Thats is good!

However, it is also displayed when not one is logged in, so it is kind of displayed all the time by default. I would like to hide the button all the time, and to users that logged in with Membership1.  
Then, only show the button to vendors that have logged in with membership2/3.

Can you please help me with this?

Thanks,

---

<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:** [June 4, 2022, 10:39am UTC](https://community.hivepress.io/t/hide-add-a-listing-button-only-to-specific-plan/349/4 "2022-06-04T10:39:24Z")

</div>

Please try this PHP snippet instead

```auto
add_filter(
    'hivepress/v1/templates/site_header_block',
    function( $template ) {
		
		if(is_user_logged_in()){
			if(hivepress()->get_version('memberships')){
				$membership = \HivePress\Models\Membership::query()->filter(['user' => get_current_user_id()])->get_first();

        		if(!$membership || your_membership_plan_id === $membership->get_plan__id()){
            		$template = hivepress()->helper->merge_trees(
						$template,
						[
							'blocks' => [
								'listing_submit_link' => [
									'type' => 'content',
								],
							],
						]
					);
        		}
    		}
		}else{
			$template = hivepress()->helper->merge_trees(
				$template,
				[
					'blocks' => [
						'listing_submit_link' => [
							'type' => 'content',
						],
					],
				]
			);
		}

    return $template;
    },
    1000
);

```

---

<div class="post-metadata">

**Author:** ![HivePressUser](https://community.hivepress.io/user_avatar/community.hivepress.io/hivepressuser/32/99_2.png) [@HivePressUser](https://community.hivepress.io/u/HivePressUser)\
**Post date:** [June 4, 2022, 8:09pm UTC](https://community.hivepress.io/t/hide-add-a-listing-button-only-to-specific-plan/349/5 "2022-06-04T20:09:55Z")

</div>

Yevhen,

It works! Excellent, this help me a lot.

Thank you 🙂

---

<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:** [July 4, 2022, 8:10pm UTC](https://community.hivepress.io/t/hide-add-a-listing-button-only-to-specific-plan/349/6 "2022-07-04T20:10:48Z")

</div>

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