# Is there a hook for pending bookings that expire?

**URL:** <https://community.hivepress.io/t/is-there-a-hook-for-pending-bookings-that-expire/9461>\
**Category:** Bookings\
**Tags:** bookings, code\
**Created:** [January 29, 2024, 10:14pm UTC](https://community.hivepress.io/t/is-there-a-hook-for-pending-bookings-that-expire/9461 "2024-01-29T22:14:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eze](https://community.hivepress.io/letter_avatar_proxy/v4/letter/e/e79b87/32.png) [@Eze](https://community.hivepress.io/u/Eze)\
**Post date:** [January 29, 2024, 10:14pm UTC](https://community.hivepress.io/t/is-there-a-hook-for-pending-bookings-that-expire/9461/1 "2024-01-29T22:14:14Z")

</div>

Is there an available hook for pending bookings that have not been confirmed or declined and expire or are about to expire?

---

<div class="post-metadata">

**Author:** ![andrii](https://community.hivepress.io/user_avatar/community.hivepress.io/andrii/32/2951_2.png) [@andrii](https://community.hivepress.io/u/andrii)\
**Post date:** [January 30, 2024, 12:36pm UTC](https://community.hivepress.io/t/is-there-a-hook-for-pending-bookings-that-expire/9461/4 "2024-01-30T12:36:42Z")

</div>

Hi,

If you mean expired, which is like not paid, we recommend using the `hivepress/v1/models/booking/update_status` hook. Then you can check there if the draft is old status and the new one is trash, then it’s expired.

​I hope this is helpful to you.

---

<div class="post-metadata">

**Author:** ![Eze](https://community.hivepress.io/letter_avatar_proxy/v4/letter/e/e79b87/32.png) [@Eze](https://community.hivepress.io/u/Eze)\
**Post date:** [February 2, 2024, 2:31am UTC](https://community.hivepress.io/t/is-there-a-hook-for-pending-bookings-that-expire/9461/5 "2024-02-02T02:31:50Z")

</div>

I’m not using marketplace, so no payment for bookings. Can I use this hook to execute a function when the pending booking expires (not confirmed or declined by vendor) and goes from pending status to trash? Like so?

```auto
add_action('hivepress/v1/models/booking/update_status', 'handle_expired_booking', 10, 3);
function handle_expired_booking($booking_id, $old_status, $new_status) {
    if ($old_status === 'draft' && $new_status === 'trash') {
        $booking_post = get_post($booking_id);
        if (!$booking_post) return;

        $vendor_user_id = get_post_field('post_author', $booking_post->post_parent);
        increment_fail_count($vendor_user_id);
    }
}

```

---

<div class="post-metadata">

**Author:** ![andrii](https://community.hivepress.io/user_avatar/community.hivepress.io/andrii/32/2951_2.png) [@andrii](https://community.hivepress.io/u/andrii)\
**Post date:** [February 2, 2024, 2:17pm UTC](https://community.hivepress.io/t/is-there-a-hook-for-pending-bookings-that-expire/9461/8 "2024-02-02T14:17:54Z")

</div>

Hi,

The hook itself and the PHP snippet look good, but then you need to modify this custom code. Please note that the vendor ID is not the post author of the booking; you need to go through the listing (`post_parent` field) and then the `post_author` of the listing.

I hope this information proves useful to you.

P.S. If you purchased a theme or extension, please enter the license key in the forum profile settings, this will enable the Premium Support badge and ensure a 24-hour turnaround time.

---

<div class="post-metadata">

**Author:** ![system](https://community.hivepress.io/user_avatar/community.hivepress.io/system/32/13990_2.png) [@system](https://community.hivepress.io/u/system)\
**Post date:** [March 3, 2024, 2:18pm UTC](https://community.hivepress.io/t/is-there-a-hook-for-pending-bookings-that-expire/9461/9 "2024-03-03T14:18:19Z")

</div>

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