I’m very new here but I’m constantly learning. However, I saw a lot of options to do this auto-publish form in WP several forums but i’m not too sure how and where to include the code? For instance, https://wordpress.org/plugins/post-my-contact-form-7/.
But where should I add this line of code?

Thanks!

add_filter('cf7_2_post_filter-quick-contact-age','filter_date_to_age',10,3);
function filter_date_to_age($value, $post_id, $form_data){
  //$value is the post field value to return, by default it is empty
  //$post_id is the ID of the post to which the form values are being mapped to
  // $form_data is the submitted form data as an array of field-name=>value pairs
  if(isset($form_data['date-of-birth']){
    //calculate the age
    $value = ....
  }
  return $value;
}

Read more here: How to create a form which will auto publish the submitted content on wordpress?


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: