Support

Account

Home Forums Front-end Issues How do you create post_title from another field(s) in ACF Pro? Reply To: How do you create post_title from another field(s) in ACF Pro?

  • @rockeypjb and @robnero

    That’s not working with PRO. I set up the front end form like this:

    acf_form( array('post_id' => 'new_post',
      'new_post' => array( 
        'post_title' => 'Temp Title',
        'post_content' => 'Temp Contents',
        'post_type' => 'members', 
        'post_status' => 'publish' ),
      'submit_value' => 'Submit',
      'field_groups' => array( 17 ),
      'return' => get_the_permalink() ) );

    I tried it without the ‘new_post’ array, knowing that’d I’d be changing the values in a pre_save_post filter, but the post wouldn’t save without it.

    Then the pre_save_post function is:

    if( $post_id == 'new_post' )
    {
      $post = array( 'post_title' => $_POST['acf']['field_2'],
        'post_content' => $_POST['acf']['field_2'],
        'post_type' => 'members', 
        'post_status' => 'publish' );
    
      $post_id = wp_insert_post( $post );
    }
    
    return $post_id;

    None of the changes made via the pre_save_post function had any effect on the post that was saved to WP.