# Show "Add Listing" button ONLY when vendor logged in

**URL:** <https://community.hivepress.io/t/show-add-listing-button-only-when-vendor-logged-in/9541>\
**Category:** HivePress\
**Created:** [February 3, 2024, 9:34am UTC](https://community.hivepress.io/t/show-add-listing-button-only-when-vendor-logged-in/9541 "2024-02-03T09:34:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fratta](https://community.hivepress.io/user_avatar/community.hivepress.io/fratta/32/7730_2.png) [@fratta](https://community.hivepress.io/u/fratta)\
**Post date:** [February 3, 2024, 9:34am UTC](https://community.hivepress.io/t/show-add-listing-button-only-when-vendor-logged-in/9541/1 "2024-02-03T09:34:37Z")

</div>

I need the Add Listing button in the top menu to only show when an ALREADY registered vendor is logged in. I found the snippet below, and it does remove the button until a user logs in, however it does not distinguish between a standard user and a vendor. Can you please help me modify it to only show the button when the logged in user is **already** a vendor?  
I have a dedicated page where vendors can register the first time and add their first listing, with a link to “/submit-listing”.  
So my flow would be, first a vendor would visit the vendors’ dedicated page, become a vendor and then the next time they login they will start seeing the “Add Listing” button in the header.  
Standard (non-vendor) logged in users will not see the “Add Listing” button.

```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:** ![MMMarketPlace](https://community.hivepress.io/letter_avatar_proxy/v4/letter/m/f17d59/32.png) [@MMMarketPlace](https://community.hivepress.io/u/MMMarketPlace)\
**Post date:** [February 3, 2024, 10:01am UTC](https://community.hivepress.io/t/show-add-listing-button-only-when-vendor-logged-in/9541/3 "2024-02-03T10:01:44Z")

</div>

Hi, i used this php snippet to hide the listing button from regular users, hopefully it works for you.

```auto
add_filter(
	'option_hp_listing_enable_submission',
	function( $value ) {
		if ( ! is_admin() && ! current_user_can( 'edit_posts' ) ) {
			return false;
		}

		return $value;
	}
);

```

---

<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:** [March 4, 2024, 10:02am UTC](https://community.hivepress.io/t/show-add-listing-button-only-when-vendor-logged-in/9541/4 "2024-03-04T10:02:26Z")

</div>

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