Problem:
The user has a form that creates a post and asks if he can implement a recurring post feature. For example, create a post for a user that has date times set for every Monday until next month
Solution:
First of all, note that a Toolset form is meant to create or edit only ONE post. To be able to create multiple posts, you will need to create custom code hooked to the cred_save_data action, that will create the additional posts.
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
To pass data from the form to your action function, you can use generic fields.
Now, it is a matter of how you intend to do it. You may want to calculate the additional posts' arrival and departure dates/times on the frontend with Javascript, and pass them to the action function.
Or you may want to pass the rule(every week until a certain date) and calculate the date on the server end inside your action function.
Then you can create additional posts with the wp_insert_post function. https://developer.wordpress.org/reference/functions/wp_insert_post/
And update the post custom fields values with the update_post_meta function. https://developer.wordpress.org/reference/functions/update_post_meta/
Note that you will need to refix your fields with "wpcf-". Check the first section of this page https://toolset.com/documentation/customizing-sites-using-php/functions/
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.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
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: Africa/Casablanca (GMT+00:00)
This topic contains 3 réponses, has 2 voix.
Last updated by leilaG Il y a 3 années et 6 mois.
Assisted by: Jamal.