Skip to content

Commit

Permalink
Added support for mapping all checkboxes of a Checkbox field to a cus…
Browse files Browse the repository at this point in the history
…tom field.
  • Loading branch information
spivurno committed Apr 20, 2022
1 parent a91f7f5 commit f585b01
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions gravity-forms/gw-update-posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,19 @@ public function update_post_by_entry( $entry, $form ) {

$meta_value = rgar( $entry, $value );

$field = GFAPI::get_field( $form, $value );

// Support mapping all checkboxes of a Checkbox field to a custom field.
if ( $field->get_input_type() === 'checkbox' && $value != (int) $value ) {
$meta_value = $field->get_value_export( $entry );
if ( is_callable( 'acf_get_field' ) ) {
$acf_field = acf_get_field( $key );
if ( $acf_field ) {
$meta_value = array_map( 'trim', explode( ',', $meta_value ) );
}
}
}

// Check for ACF image-like custom fields. Integration powered by GP Media Library.
$acf_field = is_callable( 'gp_media_library' ) && is_callable( 'acf_get_field' ) ? acf_get_field( $key ) : false;
if ( $acf_field && in_array( $acf_field['type'], array( 'image', 'file', 'gallery' ), true ) ) {
Expand Down

0 comments on commit f585b01

Please sign in to comment.