There’s some different ways to go about it. Since you’re using the pre_save_post hook you could just as easily change the title acf field value straight in the $_POST.
You would only need to remove the save_post action hook IF you’re doing a function that itself would call to the same action (like wp_insert_post or wp_update_post). That would result in an infinite loop. However you’re not using any of those so you’re fine.
Basically.. your function looks fine and it works. But it might be better practice to not use the $wpdb object. One thing you need to change tho if you continue to use this is the prepare function for $wpdb. Since you’re inserting information from variables (in the front end none the less) you should really make sure to prepare them even tho you’re sanitizing the value before insertion. https://developer.wordpress.org/reference/classes/wpdb/prepare/
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
© 2022 Advanced Custom Fields.