Home Forums General Issues get_field returning null after update Reply To: get_field returning null after update

  • Hey folks,

    This is likely happening as a result of a recent security update to the logic behind get_field() and similar functions.

    The problem was that before ACF 5.11, get_field() would return a value even if there wasn’t a matching field. This meant that it could be used to grab non-ACF data, including arbitrary options or user meta.

    However, get_field() should still work in ACF 5.11, as long as the field that you want the value for exists.

    We have seen some cases in support where fields/field groups registered via PHP (via acf_add_local_field_group(), acf_add_local_field(), and the like) are registered on a late action hook, or on a hook specific to the admin or front end, etc.

    In those cases, though the field is registered, it may not available at the time that get_field() is called, so null is returned.

    If you think that might be what’s happening to you, registering the fields on the “acf/init” action hook or just in your theme’s functions.php file should resolve the issue. Otherwise, feel free to reply here or shoot us an email so we can dig into it further.