# Only show add listing button on header if you are signed is as a specific user

**URL:** <https://community.hivepress.io/t/only-show-add-listing-button-on-header-if-you-are-signed-is-as-a-specific-user/1244>\
**Category:** HivePress\
**Created:** [August 8, 2022, 5:14am UTC](https://community.hivepress.io/t/only-show-add-listing-button-on-header-if-you-are-signed-is-as-a-specific-user/1244 "2022-08-08T05:14:08Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bpospanama](https://community.hivepress.io/letter_avatar_proxy/v4/letter/b/2bfe46/32.png) [@bpospanama](https://community.hivepress.io/u/bpospanama)\
**Post date:** [August 8, 2022, 5:14am UTC](https://community.hivepress.io/t/only-show-add-listing-button-on-header-if-you-are-signed-is-as-a-specific-user/1244/1 "2022-08-08T05:14:08Z")

</div>

Hey guys,

So I’m trying to hide the add listing buttons if you are not signed in on the page.

I tried this code snippet from a different topic but now it just doesn’t show the button even if I’m signed in as an administrator.

This is the code snippet I’m using and it’s not working.

```auto
add_filter(
    'hivepress/v1/templates/site_header_block',
    function( $template ) {
		if(is_user_logged_in()){
            		$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:** ![yevhen](https://community.hivepress.io/user_avatar/community.hivepress.io/yevhen/32/23_2.png) [@yevhen](https://community.hivepress.io/u/yevhen)\
**Post date:** [August 8, 2022, 9:29am UTC](https://community.hivepress.io/t/only-show-add-listing-button-on-header-if-you-are-signed-is-as-a-specific-user/1244/4 "2022-08-08T09:29:51Z")

</div>

Please try this PHP snippet

```auto
add_filter(
	'hivepress/v1/templates/site_header_block',
	function($template){
		if(is_user_logged_in()){
			return $template;
		}
		
		return hivepress()->helper->merge_trees(
			$template,
			[
				'blocks' => [
					'listing_submit_link' => [
						'type' => 'content',
					],
				],
			]
		);
	},
	 1000
);

```

---

<div class="post-metadata">

**Author:** ![bpospanama](https://community.hivepress.io/letter_avatar_proxy/v4/letter/b/2bfe46/32.png) [@bpospanama](https://community.hivepress.io/u/bpospanama)\
**Post date:** [August 8, 2022, 12:51pm UTC](https://community.hivepress.io/t/only-show-add-listing-button-on-header-if-you-are-signed-is-as-a-specific-user/1244/5 "2022-08-08T12:51:04Z")

</div>

It worked! Thank you!

---

<div class="post-metadata">

**Author:** ![Goyoaga](https://community.hivepress.io/letter_avatar_proxy/v4/letter/g/ec9cab/32.png) [@Goyoaga](https://community.hivepress.io/u/Goyoaga)\
**Post date:** [August 31, 2022, 5:02pm UTC](https://community.hivepress.io/t/only-show-add-listing-button-on-header-if-you-are-signed-is-as-a-specific-user/1244/6 "2022-08-31T17:02:46Z")

</div>

Hello, snippet applied, but any registered users can still List a Property… is it possible to only admit listings from SPECIFIED users (1 or 2 users)? Not all registered users? Thanks a lot

---

<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:** [September 1, 2022, 11:24am UTC](https://community.hivepress.io/t/only-show-add-listing-button-on-header-if-you-are-signed-is-as-a-specific-user/1244/7 "2022-09-01T11:24:15Z")

</div>

It is possible to hide Add a Listing button for specific user roles. Please check this topic [Add Listing Button Visible by Role | HivePress Support](https://hivepress.io/support/topic/add-listing-button-visible-by-role/#post-18421)

---

<div class="post-metadata">

**Author:** ![Goyoaga](https://community.hivepress.io/letter_avatar_proxy/v4/letter/g/ec9cab/32.png) [@Goyoaga](https://community.hivepress.io/u/Goyoaga)\
**Post date:** [September 1, 2022, 6:19pm UTC](https://community.hivepress.io/t/only-show-add-listing-button-on-header-if-you-are-signed-is-as-a-specific-user/1244/8 "2022-09-01T18:19:47Z")

</div>

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:** [October 1, 2022, 6:19pm UTC](https://community.hivepress.io/t/only-show-add-listing-button-on-header-if-you-are-signed-is-as-a-specific-user/1244/9 "2022-10-01T18:19:52Z")

</div>

Closed on October 1, 2022, 6:19pm UTC

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