Post Category & Publish Default
-
I need help to make each form post to a specific category. The categories are already made within the post, whenever a user submits the form it creates a post in that category. So for example, I have 5 different CF7 forms, form 1 needs to post in category 1, form 2 needs to post in category 2, etc.
Also I need all of the post to be published instead of going into draft. I used this snippet in my functions file. But it didn’t work. And I also noticed that this hook was specifically for that certain form. Is there a way to make all the forms to default to published?
add_action( 'cf7_2_post_status_res101_copy', 'publish_new_res101_copy',10,3); /** * Function to change the post status of saved/submitted posts. * @param string $status the post status, default is 'draft'. * @param string $ckf7_key unique key to identify your form. * @param array $submitted_data complete set of data submitted in the form as an array of field-name=>value pairs. * @return string a valid post status ('publish'|'draft'|'pending'|'trash') */ function publish_new_res101_copy($status, $ckf7_key, $submitted_data){ /*The default behaviour is to save post to 'draft' status. If you wish to change this, you can use this filter and return a valid post status: 'publish'|'draft'|'pending'|'trash'*/ return 'publish'; }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Post Category & Publish Default’ is closed to new replies.