Skip Navigation

[Resolved] Auto change taxonomy after specified time

This support ticket is created 3 years, 9 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Karachi (GMT+05:00)

Author
Posts
#1952091

Sorry for so many questions in recent days. I want to choose the best way to create my website and i promise i will let you rest later 🙂

So is it possible to auto change taxonomy after specified time ?

I am creating an advertising portal where adding ads is free. Later, the user will be able to buy an advertisement promotion for a specified period of time (e.g. 30 days). I would like the advertisement to be transferred to the Taxonomy "Type of advertisement> Promoted" after the purchase and disappear from it after specified time.

#1953405

Hi,

Thank you for contacting us and I'd be happy to assist.

To achieve this, you can use the automatic post expiration feature, as explained here:
https://toolset.com/course-lesson/setting-up-automatic-post-expiration/

You can set the promoted posts to expire in a set period (for example 30 days), but let them keep the original status after expiration.

Then using a custom function attached to the "cred_post_expiration_custom_actions" hook, you can remove that particular taxonomy term from the post, when it expires:
( https://toolset.com/documentation/programmer-reference/cred-api/#cred_post_expiration_custom_actions )

Example:


add_filter('cred_post_expiration_custom_actions', 'my_custom_actions', 10, 3);
 
function my_custom_actions($custom_actions, $post_id, $form_data) {
    wp_remove_object_terms( $post_id, 'promoted', 'type-of-advertisement' );
    return $custom_actions;
}

Note: you'll replace "promoted" and "type-of-advertisement" with the actual slug of the term "Promoted" and the taxonomy "Type of advertisement", respectively.

The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through the active theme's "functions.php" file.

regards,
Waqar