Filling an attribute value on payment


I would like to automatically fill the value of an attribute (in the booking section) after a payment is complete.

Could you please give me some tricks or reflection to succeed ?



You can use this PHP hook 'hivepress/v1/models/listing/update_status', and in this snippet, specify bookings -> set_attribute_name -> save_attribute_name.

​I hope this is helpful to you.

Thank you Andrii
I check it and keep you updated

Hi Andrii,
I’m working with Christophe on this request. We have this use case :

  • Booking attribute has been defined in Hivepress bookings config section (attribute name “link”, type is a URL), not visible on front, empty value by default
  • User books a listing
  • booking #1 created in Woocommerce
  • booking #2 created in Hivepress
    When booking #2 is created, we’d need to programmatically add a link value, but I can’t seem to find a working hook to proceed.

Maybe you have some sample hook that you could share ?

I’m trying with something like this in functions.php :

// Update attribute when reservation is created
function update_booking_attribute($booking_id) {
    // Get booking ID
    $booking = hivepress()->bookings->get_booking($booking_id);

    // Check if booking exists
    if ($booking) {
        // Update attribute
        $booking->set_meta('link', '');
add_action('hp_booking_created', 'update_booking_attribute');

This code is not a good way to do it, it seems.

Thanks in advance,

If I understand correctly, you have created a booking attribute with the field name link. Please try this PHP code snippet if you want to set some value for this attribute when the booking is confirmed.

	function($booking_id, $new_status, $old_status, $booking){
		if('publish' === $new_status){

Thank you so much yevhen !
It works perfectly

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