Home › Forums › ACF PRO › $_POST in new post title the first 3 characters of a field value › Reply To: $_POST in new post title the first 3 characters of a field value
This did the trick for me!
basically i used this to get the first 3 characters: mb_strimwidth($_POST['acf']['field_5a6b343038f0c'], 0, 3 )
Below you can see the function:
function acf_review_before_save_post($post_id) {
if (empty($_POST['acf']))
return;
$_POST['acf']['_post_title'] =$_POST['acf']['field_5a6770a3c509d'].' '.mb_strimwidth($_POST['acf']['field_5a6b343038f0c'], 0, 3 ).' '.$_POST['acf']['field_5a5f76d271881'].' '.date("d/m/Y", strtotime($_POST['acf']['field_5a6b3543bf97a']));
return $post_id;
}
add_action('acf/pre_save_post', 'acf_review_before_save_post', -1);
Thanks for your response!
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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.