Home Forums Backend Issues (wp-admin) Saving Gravity Forms multi select to ACF multi select


Saving Gravity Forms multi select to ACF multi select

  • Hi – So I have the GF checkbox to ACF checkbox dealt with, basically serialize the data:

    `$post_data[‘post_custom_fields’][$key_name] = serialize(explode(‘,’, $post_data[‘post_custom_fields’][$key_name]));

    But when trying to do similar for multi select, the multi select ACF only selects first option.

    This is a problem because when the post is created via GF to Custom Post Type, and then the post is saved again, the serialized data from the use input (which shows multi-selections) is saved over with the first selection).

    As in, I use GF to Custom Post Type to create a post with a multi-select meta field. Before saving that post I var_dump out the get_field( $post_id, ‘multi_select’) and i see the two user selected values. So they are there, but when the post is then saved, published, etc, since the ACF multi-select only showing the fist value, the user submitted values are overwritten.

    So, how to get GF multi-select values saved into an ACF multi select. Serializing the data doesn’t appear to work like it does with checkboxes. // the checkbox solution //

  • I don’t know too much about GF, but I had a similar problem using an import tool importing to a select field. In my case the problem was that the data being imported had a space after each comma, you might check that. multi select fields are saved the same as checkbox fields but if you’re exploding the values with “,” as the separator and it is actually “, ” then all of your values will have a space at the beginning and this could be why ACF is not seeing them.

  • Hi Hube2 – that is a good suggestion but I don’t think it is the issue. The data is being exploded and then serialized, so it looks like this using a var_dump | s:44:”a:2:{i:0;s:8:”Choice A”;i:1;s:8:”Choice B”;}”;

    Thankfully we can get around using multi-select with just multiple checkboxes. But I would like to know the solution. It seems that there is a plugin in the making here, GF+Custom Post Type to ACF.

  • It’s odd that you can get it to work with a checkbox and not a select since ACF stores both of these the same way.

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

The topic ‘Saving Gravity Forms multi select to ACF multi select’ is closed to new replies.