How to add PHP snippets

Hi there,
I was trying to install the following snippet in the functions.php of the ExpertHive Theme, but it broke my site. Where is the correct location for this?

//Update booking
add_action(
	'hivepress/v1/models/booking/update_status',
	function( $booking_id, $new_status, $old_status, $booking , $listing) {

		// Check status.
		if ( 'publish' !== $new_status ) {
			return;
		}

		// Send request.
		wp_remote_post(
			'https://hooks.zapier.com/hooks/catch/195018/3qhudlg',
			[
				'body' => [
				'booking_start_time' => date('Y-m-d', $booking->get_start_time());
				'booking_end_time' => date('Y-m-d', $booking->get_end_time());
				'booking_client' => $booking->get_user__id(),
				'booking_consultant' => $listing->get_user__id(),
				'booking_order' => $order_id,
				],
			]
		);
	},
	1000,
	4
);

Nevermind, seems like I had an error in my code.

However, now with this code, when I make a booking it gives a critical error?

Hi,

Please make sure you add this PHP snippet using this doc How to add custom code snippets - HivePress Help Center. Also, please note that we recommend that you do not manually modify our product files, as any update from us will automatically remove this customization. Therefore, we recommend using the recommendations described in the document.

​I hope this is helpful to you.

Thanks, I think it works now.

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