Vendor profile on my account

I add 3 questions here to avoid multiple posts.

  1. I use this snippet to add link from my account to vendor profile:
add_filter(
	'hivepress/v1/menus/user_account',
	function ( $menu ) {
		if ( is_user_logged_in() ) {
			$vendor_id = HivePress\Models\Vendor::query()->filter(
				[
					'user' => get_current_user_id(),
				]
			)->get_first_id();

			if ( $vendor_id ) {
				$menu['items']['vendor_view'] = [
					'label'  => 'Vendor profile',
					'url'    => hivepress()->router->get_url( 'vendor_view_page', [ 'vendor_id' => $vendor_id ] ),
					'_order' => 10,
				];
			}
		}

		return $menu;
	},
	1000
);

But the problem is when the user creates a listing and waits for the administration to approve his listing the link “vendor profile” takes him to the 404 page because the listing has not yet been approved.
What should I add to this snippet to check if vendor first listing is approved then insert the vendor profile link in my account?

  1. How the approval works now? I can’t understand. when the vendor creates a new listing the only option is to approve or disapprove it?
    Is it possible to make that after the vendor creates his listing how can I disapprove the listing and give him a reason why? after that give him a chance to moderate the listing and then send it again to admin for approval.

  2. After the vendor received an order he receive 2 emails one from the booking plugin and one from the marketplace plugin (I know because have seen the strings through loco translate).

The first email the vendor receive is: Hi, %user_name%! A booking of “%listing_title%” has been confirmed, click on the following link to view it: %booking_url%

And the second email vendor receives: Hi, %user_name%! You’ve received a new order %order_number% of %order_amount%, click on the following link to view it: %order_url%

It should be this way? I think it is a little confusing to receive 2 emails.

Hi,

  1. Please try adding the ‘status’ => ‘publish’, parameter to the vendor query (where the user ID is set), then the link should appear only if the vendor profile is published.

  2. There’s no such feature yet, but there’s a temporary workaround if you contact vendor via email.

  3. If you use both Marketplace and Bookings, please try disabling one of these emails (e.g. the order one) by creating an empty email in HivePress/Emails.

Do you mean add ‘status’ => ‘publish’ like that?

add_filter(
	'hivepress/v1/menus/user_account',
	function ( $menu ) {
		if ( is_user_logged_in() && ‘status’ => ‘publish’ ) {
			$vendor_id = HivePress\Models\Vendor::query()->filter(
				[
					'user' => get_current_user_id(),
				]
			)->get_first_id();

			if ( $vendor_id ) {
				$menu['items']['vendor_view'] = [
					'label'  => 'Vendor profile',
					'url'    => hivepress()->router->get_url( 'vendor_view_page', [ 'vendor_id' => $vendor_id ] ),
					'_order' => 10,
				];
			}
		}

		return $menu;
	},
	1000
);

If it’s not right can you send me the right snippet, it will be very helpful for me :pray:

Please try this one:

add_filter(
	'hivepress/v1/menus/user_account',
	function ( $menu ) {
		if ( is_user_logged_in() ) {
			$vendor_id = HivePress\Models\Vendor::query()->filter(
				[
					'user' => get_current_user_id(),
					'status' => 'publish',
				]
			)->get_first_id();

			if ( $vendor_id ) {
				$menu['items']['vendor_view'] = [
					'label'  => 'Vendor profile',
					'url'    => hivepress()->router->get_url( 'vendor_view_page', [ 'vendor_id' => $vendor_id ] ),
					'_order' => 10,
				];
			}
		}

		return $menu;
	},
	1000
);
1 Like