Hello, i’m using ACF forms on a custom CPT and using some fields to create the post title by using the following code:
function taktiko_mitroo_title_updater( $post_id )
{
if ( get_post_type( $post_id ) == 'taktiko-mitroo' ) {
$my_post = array();
$my_post['ID'] = $post_id;
$my_post['post_title'] = mb_strtoupper(get_field( 'doctors_lname', $post_id ), 'UTF-8') . ' ' . mb_strtoupper(get_field( 'doctors_fname', $post_id ), 'UTF-8') ;
wp_update_post ( $my_post ) ;
}
}
// run after ACF saves the $_POST['fields'] data
add_action('acf/save_post', 'taktiko_mitroo_title_updater');
When in the back-end, and I update a post, all works correctly.
When using an ACF form frontend and using the submit button, the post updates correctly, but a new blank post with the same title is created.
I’m guessing there’s an issue with my code if someone can help me spot it.