Vendor email shortcode for Contact Form 7

Hi, I don’t like that users have to sign in to send a message about a listing so I have created a custom form for the listing page for users to send messages to the vendor. The issue is I need the email to go to the vendor and not the site admin [_site_admin_email]. I am using Contact Form 7. Does anyone know the email shortcode I could slot into the ‘To’ field so this happens?

I am using the following PHP script to display the contact form on the listing page so another option would be to edit the code to change the script to implement my requirement above, but I am not good with PHP. Any help would be much appreciated:

add_filter(
	'hivepress/v1/templates/listing_view_page/blocks',
	function( $blocks, $template ) {
		$listing = $template->get_context( 'listing' );
		if ( $listing ) {
			$blocks = hivepress()->helper->merge_trees(
				[ 'blocks' => $blocks ],
				[
					'blocks' => [
						'listing_actions_primary' => [
							'blocks' => [
								'vendor_email_link' => [
									'type'    => 'content',
									'content' => do_shortcode( '[contact-form-7 id="46bfaf7" title="Reply To Listing"]' ),
									'_order'  => 5,
								],
							],
						],
					],
				]
			)['blocks'];
		}	
		
		return $blocks;
	},
	1000,
	2
);

Thanks

If anyone else is trying to do this I figured out the right syntax to use in contact form 7 so the posting vendor receives the email instead of site admin. Insert [_post_author_email] into the “To” field on the form.

1 Like

Thanks for sharing the solution!

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