Problem: I have a Form that contains a date field. I would like to use the date from the field as the post date. The posts are published in "Pending Review" status.
Solution: You can't set the publish date of a Pending Review post, but you can set the last modification date using this code:
add_action('cred_save_data', 'my_save_data_action',10,2); function my_save_data_action($post_id, $form_data) { // if a specific form $forms = array( 123, 456, 789 ); if ( in_array( $form_data['id'], $forms) ) { // nothing below here was changed for the comma-separated list of IDs $timestamp = get_post_meta($post_id, 'wpcf-datum-des-bildes', true); $date = date('Y-m-d H:i:s', $timestamp); if(isset($timestamp)){ $args = array( 'ID' => $post_id, 'post_modified' => $date ); wp_update_post( $args ); } }
Relevant Documentation:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
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.
Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
Dieses Thema enthält 9 Antworten, hat 2 Stimmen.
Zuletzt aktualisiert von vor 6 Jahren.
Assistiert von: Christian Cox.