Title: Publish posts automatically
Last modified: July 2, 2023

---

# Publish posts automatically

 *  Resolved [palopoliart7](https://wordpress.org/support/users/palopoliart7/)
 * (@palopoliart7)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/publish-posts-automatically/)
 * Hello! I used the hook to publish automatically products when the form is submitted.
   But it does not seem to work. Here is my code :
 *     ```wp-block-code
       add_filter( 'cf7_2_post_status_product', 'publish_new_product',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_product($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'*/
           if ($ckf7_key == '4022' || $ckf7_key == '6459'){
       		return 'publish';
       	} else{
       		return $status;
       	}
   
         }
       ```
   
 * I use the form ID as $ckf7_key, is that the problem ? I could not find the form
   KEY.
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fpublish-posts-automatically%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Aurovrata Venet](https://wordpress.org/support/users/aurovrata/)
 * (@aurovrata)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/publish-posts-automatically/#post-16885686)
 * > I use the form ID as $ckf7_key, is that the problem ? I
 * yes, the `$ckf7_key` is the form post slug which you can find in the form table
   or the _information_ metabox in the form editor page
 *  Thread Starter [palopoliart7](https://wordpress.org/support/users/palopoliart7/)
 * (@palopoliart7)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/publish-posts-automatically/#post-16886451)
 * Thank you! Yes that was it 🙂
 *  Plugin Author [Aurovrata Venet](https://wordpress.org/support/users/aurovrata/)
 * (@aurovrata)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/publish-posts-automatically/#post-16886536)
 * great. Do leave a [review](https://wordpress.org/support/plugin/post-my-contact-form-7/reviews/)
   when you have moment to spare.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Publish posts automatically’ is closed to new replies.

 * ![](https://ps.w.org/post-my-contact-form-7/assets/icon-256x256.png?rev=1985682)
 * [Post My CF7 Form](https://wordpress.org/plugins/post-my-contact-form-7/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/post-my-contact-form-7/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/post-my-contact-form-7/)
 * [Active Topics](https://wordpress.org/support/plugin/post-my-contact-form-7/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/post-my-contact-form-7/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/post-my-contact-form-7/reviews/)

## Tags

 * [hook](https://wordpress.org/support/topic-tag/hook/)
 * [product](https://wordpress.org/support/topic-tag/product/)
 * [published](https://wordpress.org/support/topic-tag/published/)

 * 3 replies
 * 2 participants
 * Last reply from: [Aurovrata Venet](https://wordpress.org/support/users/aurovrata/)
 * Last activity: [2 years, 10 months ago](https://wordpress.org/support/topic/publish-posts-automatically/#post-16886536)
 * Status: resolved