Is there a hook that triggers on listing expiration. I’m trying to set some custom code so that the post doesn’t go into a draft status. I want to set a custom meta to indicate expiration instead of going into draft.
I’ve checked the listing expire email hook, but it doesn’t seem to expose the post(listing) object
Hi,
Please try using the expiration email send hook [hivepress/v1/emails/{email_name}/send]. It allows you to access the email object from the second parameter and retrieve the available tokens via $email->get_tokens(). Among them, there will be a listing token, which represents the listing object itself.
Using that object, you can change the listing status back to publish.
Please note that several things in the codebase are tied to the draft status. For example, the Expired label is displayed only when the listing is in draft status and the expiration date is in the past. Changing the status may therefore affect this and other related behaviors.
Hope this helps
Is there a way we can show that a listing has expired to the users instead of going to draft. We want to keep the listing active for sometime, then delete if a user fails to renew lisitng. People usually forget to renew these listings. We want to display a listing expired notice on the frontend
An expired listing means it’s in draft status with a past expiration date. For what you’re describing, please consider using the Storage Time setting instead, that’s what actually moves listings to Trash. Expired listings can still be seen by the user who posted them and can be renewed (plus an email is sent to notify them), they’re just not visible to public users anymore.
Hope this helps.
Wishing you a relaxing weekend 