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 );
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.