• Resolved palopoliart7

    (@palopoliart7)


    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 :

    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 to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Publish posts automatically’ is closed to new replies.