Support

Account

Home Forums General Issues Using a field to define a new post title with acf_form Reply To: Using a field to define a new post title with acf_form

  • Hi @edcraddock,

    I’m trying to do the same thing. Basically, what you need to do is add a hook on saving the post, and assemble the title from the components.

    add_action('acf/save_post', 'my_save_post');
    function my_save_post($post_id){
      // make sure this post type is the kind we want
    
      // get the first and last name fields
      // (or whatever field(s) you want to convert into the title
    
      // update the post title (if there isn't one already)
      // https://developer.wordpress.org/reference/functions/wp_update_post/
    }
    

    I’m using this help page to figure this out: https://www.advancedcustomfields.com/resources/using-acf_form-to-create-a-new-post/ (look at the contact form example)

    the acf/save-post hook happens AFTER the post is inserted, so you can use wp_update_post to update the title.

    (I’ll post my code here once I actually get it working)