Support

Account

Home Forums Front-end Issues Set title on acf_form Reply To: Set title on acf_form

  • As an example, this will set the post title on save or update from input fields.

    <?php // SET TITLE ON SAVE & UPDATE
    function my_post_title_updater($post_id) {
    	if ( get_post_type( $post_id ) == 'account' ) {
    		$my_post = array(
    			'ID'           => $post_id,
    			'post_title'   => get_field( 'last_name', $post_id ) . ', ' . get_field( 'first_name', $post_id ),
    		);
    		wp_update_post( $my_post );
    	}
    }
    add_action('acf/save_post', 'my_post_title_updater', 20); // run after ACF saves the $_POST['fields'] data
    ?>