I understand, but somehow this is the opposite of what Forms does.
It offers you expiration settings so to do something if the post expires (put the post in a private state, for example)
It does not offer the opposite, to expire a post when a status changes... it is kind of pointless doing it, as the only you can do with a Post Expiration what you cannot do with a Date field is... automatically bind the CRON to fire the actions you set on the date reached.
So, the idea here is to let expire a post and then change the post status, nothing else (from the point of view for what it was created).
Once the post expires, Forms takes care and fires the actions to put the post in that state as set in the form
Now, the hook you used (cred_post_expiration_custom_actions) documented as below linked, hooks in cred_save_data later, so that is when the post is saved (also offered as API hook on itself):
https://toolset.com/documentation/user-guides/automatic-post-expiration/#what-happens-when-posts-expire
In the code this looks fine, it is hooked last, so it will overwrite whatever came before.
If you update expiration fields on that moment, they should save fine.
But, the code used is not clear to me.
The API allows to update meta fields.
function my_custom_actions($custom_actions, $post_id, $form_data) {
$custom_actions[] = array( 'meta_key' => 'advert_active', 'meta_value' =>'false' );
return $custom_actions;
}
However the API used there cannot change the post status with this, it only addresses meta_keys
If the purpose is, to:
- expire a post when something happens to a post (opposite of what Forms does now) then this is a new feature I can request.
However, I miss the point of doing this
- or, re-set a new expiration time, after the post is expired, and changes status, that I can request as well to be added
However, I see not many people yet requesting this, we let the Developers evaluate this.
Please accept my apologies if I misunderstood.