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