Skip Navigation

[Resolved] cred_post_expiration_custom_actions issue

This thread is resolved. Here is a description of the problem and solution.

Problem:
CRED hook "cred_post_expiration_custom_actions" not working

Solution:
To fire the action "cred_post_expiration_custom_actions"- you need to activate the "Expiration date:" setting from CRED from.

You can find proposed solution, in this case, with the following reply:
https://toolset.com/forums/topic/cred_post_expiration_custom_actions-issue/#post-809547

Relevant Documentation:
https://toolset.com/documentation/user-guides/automatic-post-expiration/

This support ticket is created 6 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 5 replies, has 2 voices.

Last updated by Kostas 6 years, 6 months ago.

Assisted by: Minesh.

Author
Posts
#808752

I am using below code:

function my_custom_expire_actions($custom_actions, $post_id, $form_data) {
    $custom_actions[] = array( 'meta_key' => 'wpcf-sample_active', 'meta_value' => '0' );
    return $custom_actions;
}

add_filter('cred_post_expiration_custom_actions', 'my_custom_expire_actions', 10, 3);

so when a CPT sample expires, set its sample_active field to 0.
Unforunately, when sample expires, sample_active field stays to its default 1.
What am I missing here?

Thank you!

#809368

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - I see that you did not activated the post expiration setting for your CRED form:
=> hidden link

Please check following screenshot:
=> hidden link

So - please activate the "Expiration date:" settings by clicking on the checkbox and set your desired values. For example - see this image:
=> hidden link

Once you set the post expiration values - create a new post with old date and check it it the post is expired in 2 minutes or not.

More info:
=> https://toolset.com/documentation/user-guides/automatic-post-expiration/

#809395

Hi Minesh,

Thank you for responding.

The expiration date is set (last minute of current month) in my functions.php as an action on the cred_save_data hook.
Is that not enough?

Regards,
Kostas

#809471

The post expires fine at last minute of current month, it is the expiration custom action that is not triggered.

#809547

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Ok - I see you added the custom post expiration time using CRED hook that you added to funcitons.php file.

To fire the action - you need to activate the "Expiration date:" setting from CRED from.

Please try following steps:
- Activate the "Expiration date:" setting from CRED from
- Create a new post
- check if it fires the expiration custom action

It should work now.

#809654

Yes, it works now 🙂

So, added custom post expiration time using CRED hook in functions.php is actually overwriting the expiration date settings from CRED form GUI.

This should be mentioned in the docs somewhere, to avoid confusion!

Thanks a lot Minesh,
Kostas