Home Forums Bug Reports acf_get_value notice incorrect Reply To: acf_get_value notice incorrect

  • I did a bit more testing on my workaround and I noticed something unexpected with the return type.
    When fetching by name a toggle (true/false) field returns a string "1" but doing the same with a key returns a bool true.

    I am now using the following workaround:

    add_filter('acf/pre_load_value', 'getFieldByName', 10, 3);
    function getFieldByName(mixed $value, string|int $post_id, array $field): mixed
        if (!$field['key']) {
            $name = $field['name'];
            $fields = acf_get_local_store('fields');
            if ($fields && array_key_exists($name, $fields->aliases)) {
                return get_field($fields->aliases[$name], $post_id);
        return $value;