Allow hosts to view a guest's account when a booking is requested

My hosts want to be able to view a guest’s account when a booking is requested. I have some custom fields that hosts need to have visibility of. How can I make this possible?

Please try this PHP code snippet as a temporary solution. But please note that it can require further customization. If you are not familiar with the code customization, then please consider hiring someone for custom work https://fvrr.co/32e7LvY

add_filter(
	'hivepress/v1/templates/booking_view_page/blocks',
	function($blocks, $template){
		if(!get_option('hp_user_enable_display')){
			return $blocks;
		}
		
		$listing = $template->get_context('listing');
		
		if(!$listing){
			return $blocks;
		}
		
		$vendor = $listing->get_vendor();
		
		if(!$vendor || get_current_user_id() !== $vendor->get_user__id()){
			return $blocks;
		}
		
		return hivepress()->template->merge_blocks(
			$blocks,
			[
				'booking_sidebar' => [
					'blocks' => [
						'custom_booking_user_block' => [
							'type'     => 'template',
							'template' => 'user_view_block',
							'_order'   => 30,
						],
					],
				],
			],
		);
	},
	1000,
	2
);
3 Likes

Hi, this php snippet didn’t work for me. Do you have any other idea on how to make it work?

Hi,

We tested this snippet, and it seems to work. Please make sure you are using the Code Snippet plugin How to add custom code snippets - HivePress Help Center. Also, please disable third-party plugins and customizations (if there are any) and check if this issue persists. If you use a caching plugin, ensure that caching is disabled for logged-in users.

Hi Andrii,
through this plugin, the host can only see the name of the user and since when they are registered. Is it possible to show all information from the profile? I have some additional input fields

Hi,

Yes, it is possible, but it will require additional custom implementation.

This is great, I had enquired about getting a link to the user who wants to book but including it in the booking request is perfect. Thanks.

Like Sophia I want to add the additional attributes that I have included to this. you mention additional custom implementation. Any recommendations where to start with this? I have searched high and low in templates but I have had no luck. PLEASE HELP :slight_smile:

Hi,

To show additional user information, you’ll have to make changes to the PHP code provided in the above topic.

Great thanks, any suggestions on where to start. My coding level is not great and i dont want to break anything. Someone mentioned fiver?

Hi,

Unfortunately, there is no simple solution. It requires a detailed study of the code and custom implementation. If customizations are required for your site, please try customizing it using the collection of code snippets Search · user:hivepress · GitHub and other developer resources, or consider hiring someone for custom work https://fvrr.co/32e7LvY

Alternatively, you can send your proposal via this link, and we will estimate the implementation Request a Quote

I need this feature as well! It seems like we just need users to have the same kind of profiles as hosts, with the option to make them public or private?

Hi,

Unfortunately, there is no such feature yet. But we plan to add it as soon as possible.

Hi, how could I diplay the vendor_view_block instread of the user_view_block in the code snippet yevhen provided the 23 april?
I tried like this but didn’t work:

add_filter(
	'hivepress/v1/templates/booking_view_page/blocks',
	function($blocks, $template){
		if(!get_option('hp_user_enable_display')){
			return $blocks;
		}
		
		$listing = $template->get_context('listing');
		
		if(!$listing){
			return $blocks;
		}
		
		$vendor = $listing->get_vendor();
		
		if(!$vendor || get_current_user_id() !== $vendor->get_user__id()){
			return $blocks;
		}
		
		return hivepress()->template->merge_blocks(
			$blocks,
			[
				'booking_sidebar' => [
					'blocks' => [
						'custom_booking_user_block' => [
							'type'     => 'template',
							'template' => 'vendor_view_block',
							'_order'   => 30,
						],
					],
				],
			],
		);
	},
	1000,
	2
);

Thanks in advance.
Emilio

Please try this PHP code snippet instead

add_filter(
	'hivepress/v1/templates/booking_view_page/blocks',
	function($blocks, $template){
		$booking = $template->get_context('booking');
		
		if(!$booking){
			return $blocks;
		}
		
		$listing = $booking->get_listing();
		
		if(!$listing){
			return $blocks;
		}
		
		$vendor = $listing->get_vendor();
		
		if(!$vendor){
			return $blocks;
		}
		
		$template->set_context('vendor', $vendor);
		
		return hivepress()->template->merge_blocks(
			$blocks,
			[
				'booking_sidebar' => [
					'blocks' => [
						'custom_booking_user_block' => [
							'type'     => 'template',
							'template' => 'vendor_view_block',
							'_order'   => 30,
						],
					],
				],
			],
		);
	},
	1000,
	2
);