Remove the button "Add Listing" for Contributors

Hello,

I my site I only allow 1 listing per vendor. I was wondering if once they create their first listing i can remove the “add listing” button from the top right.

I already removed the button for non logged in users using this code and it worked well…just wondering if I can also remove it once they added one listing. Thanks

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
);

Hi,

Please check the solution in this topic Remove add listing button, when one listing is created

1 Like

Hello Andrii,

Its not working for me. the button now disappears even for “Subscriber” users without a listing so there is no way to add a listing for them.

I would like for users without a listing to be able to see the button, and I guess once they add a listing they become “Contributor” user. So hide the add listing button for “Contributor” users

Hi,

Please try this PHP snippet:


add_filter(
    'option_hp_listing_enable_submission',
    function( $value ) {
       
        if ( ! is_admin() && hivepress()->request->get_context( 'listing_count' ) >=1 ) {
            return false; // do not display button
        }

        return $value;
    }
);

Thank you so much, Andrii! this works perfectly.

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