chrisH-10
Support threads created in the last 30 days: 0
Favorite Forum Topics
This user has no favorite topics.
Forum Topics Created
Status | Topic | Supporter | Voices | Posts | Freshness |
---|---|---|---|---|---|
Create a link to a page that embeds a content edit form
Started by: chrisH-10 in: Toolset Professional Support |
2 | 5 | 7 years, 2 months ago | ||
Set publish date of post
Started by: chrisH-10
in: Toolset Professional Support
Problem: I would like to set the publish date and time of a post within the CRED Form used to create that post. Solution: There's no post publish date field built into CRED, so this will require some custom code and a generic field. Add a generic date field to your CRED form, then add this code to functions.php: add_action('cred_save_data', 'set_post_date_to', 100, 3); function set_post_date_to($post_id, $form_data) { if( $form_data['id'] == 12345 ) { $newDate = $_POST['set-new-date']['datetime'] . ' 00:00:00'; $my_post = array( 'ID' => $post_id, 'post_date' => $newDate, 'post_date_gmt' => $newDate, 'post_status' => 'future' ); // Update the post into the database wp_update_post( $my_post ); } } - Change the form id 12345 to match your form. Relevant Documentation: |
2 | 5 | 7 years, 2 months ago |