Home Forums General Issues autofill fields using acf_update_value


autofill fields using acf_update_value

  • According to the documentation (if I am reading it correctly) the following should autofill myACFfieldname field;

    contained within themes>functions.php

    function my_acf_update_value( $value, $post_id, $field  )
        $value = "Autofill-Text";
        return $value;
    add_filter('acf/update_value/name=myACFfieldname', 'my_acf_update_value', 10, 3);

    Appreciate if somebody can point out the obvious misunderstanding.

  • Hi @rotorbit69,

    Thanks for the post.

    Yes the code appears to be correct and the set value should override the one entered on the post edit page.

    Please debug your code to check if the new value has been set through:

    $field_value = get_field('myACFfieldname');
    echo '<pre>';
    	var_dump( $field_value );
    echo '</pre>';
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘autofill fields using acf_update_value’ is closed to new replies.