Support

Account

Home Forums Front-end Issues Possible to reference grouped field by field_key in acf/save_post?

Helping

Possible to reference grouped field by field_key in acf/save_post?

  • I’m trying to use a field key for a field in a group with the acf/save_post action to set/update a post title. It was working as documented for a simple text field, but I’m not able to figure out how to reference a grouped field by its key.

    I tried to reference the sub field of the group directly, and tried to reference the group then the sub field (i.e. [‘acf’][‘field_123456789a’]_[‘field123456789b’]), but it didn’t seem to work. Is there a syntax for this, or have I just got it all wrong?

    For reference:
    before (this was working when it was just a text field)
    ($_POST['acf']['field_123456789a'])

    after (not working after I put the text field into a group)
    ($_POST['acf']['field_123456789a']_['field123456789b'])

  • I doubt it’s as easy as a typo, but…

    ($_POST[‘acf’][‘field_123456789a’]_[‘field123456789b’])

    Check the real code and make sure that underscore isn’t actually there between the two bracketed key refernces, so:

    ($_POST[‘acf’][‘field_123456789a’][‘field123456789b’])

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Possible to reference grouped field by field_key in acf/save_post?’ is closed to new replies.