Support

Account

Home Forums General Issues Check box values from gravity form not stored in ACF check box Reply To: Check box values from gravity form not stored in ACF check box

  • Here how to do it :
    (https://docs.gravityforms.com/gform_advancedpostcreation_post_after_creation/)

    The scope of this example is limited to form id 1 and field id 18, you need to update these values to apply to your own form and field.
    Replace my_custom_field_key with your custom field meta key

    add_filter( 'gform_advancedpostcreation_post_after_creation_1', 'apc_serialize_checkboxes', 10, 4 );
    function apc_serialize_checkboxes( $post_id, $feed, $entry, $form ) {
     
        // Checkboxes field id.
        $field_id = 18;
     
        // Get field object.
        $field = GFAPI::get_field( $form, $field_id );
      
        if ( $field->type == 'checkbox' ) {
            // Get a comma separated list of checkboxes checked
            $checked = $field->get_value_export( $entry );
      
            // Convert to array.
            $values = explode( ', ', $checked );
      
        }
     
        // Replace my_custom_field_key with your custom field meta key.
        update_post_meta( $post_id, 'my_custom_field_key', $values );
    }