Support

Account

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!