Support

Account

Home Forums Backend Issues (wp-admin) Saving hidden fields in a custom field Reply To: Saving hidden fields in a custom field

  • Hi

    after u create front end form pls put following function in your function.php, add the required filed to post

    add_filter(‘acf/pre_save_post’ , ‘my_pre_save_post’ );
    function my_pre_save_post( $post_id ) {
    // check if this is to be a new post
    if( $post_id != ‘new’ ) {
    return $post_id;
    }

    $field = $_POST[‘fields’];
    $post_title = $_POST[‘fullname’];
    $post_content = $field[‘edit_test2’];
    $post = array(
    ‘post_status’ => ‘draft’ ,
    ‘post_title’ => $post_title,
    ‘post_content’ => $post_content,
    ‘post_type’ => ‘page’

    );
    $newpost_id=wp_insert_post($post);
    if($newpost_id!=0)
    {

    $fullname=$_POST[‘fullname’];
    $address=$_POST[‘address’];
    add_post_meta($newpost_id,’FullName’, $fullname);
    add_post_meta($newpost_id, ‘address’, $address);
    }
    }

    You can also refer following article
    http://www.advancedcustomfields.com/resources/tutorials/using-acf_form-to-create-a-new-post/