Plugin Directory

Changeset 3297824


Ignore:
Timestamp:
05/21/2025 07:51:49 AM (11 months ago)
Author:
engagebay
Message:

Version 3.1.4: Fixed address sync issue

Location:
engagebay-gravity-forms
Files:
24 added
3 edited

Legend:

Unmodified
Added
Removed
  • engagebay-gravity-forms/trunk/engagebay-gravityforms.php

    r3179179 r3297824  
    22/*
    33  Plugin Name: EngageBay Gravity Forms Addon
    4   Plugin URI: https://www.engagebay.com/new-gravity-forms
     4  Plugin URI: https://www.engagebay.com/gravity-forms
    55  Description: EngageBay Gravity Forms integration plugin for gravity forms. Sync form entries to my website easily.
    6   Version: 3.1.3
     6  Version: 3.1.4
    77  Requires at least: 4.0
    8   Tested up to: 6.6.2
     8  Tested up to: 6.8.1
    99  Author: EngageBay
    1010  Author URI: https://www.engagebay.com
  • engagebay-gravity-forms/trunk/includes/engagebay-gf-addon-form-handler.php

    r3072561 r3297824  
    11<?php
    22
    3 class EngageBayGFAddonFormHandler
    4 {
    5     public function eb_gf_add_actions()
    6     {
    7         add_action('gform_after_submission', array($this, 'eb_gf_on_submit_form'), 10, 2);
    8     }
    9 
    10     public function eb_gf_settings($form)
    11     {
    12         return array(
    13             array(
    14                 'title' => __('Gravity Form Field Mapping with EngageBay Fields', 'engagebaygfaddon'),
    15                 'fields' => array(
    16                     array(
    17                         'name' => 'mapGravityFormsToEngagebay',
    18                         'label' => __('Configuration', 'engagebaygfaddon'),
    19                         'onclick' => "jQuery(this).parents('form').submit();",
    20                         'type' => 'checkbox',
    21                         'choices' => array(
    22                             array(
    23                                 'label' => sprintf(__('Integrate %s with EngageBay', 'engagebaygfaddon'), $form['title']),
    24                                 'name' => 'engagebayMapEnabled',
    25                             ),
    26                         ),
    27                     ),
    28                 ),
    29             ),
    30             array(
    31                 'title' => __('Fields Mapping', 'engagebaygfaddon'),
    32                 'name' => 'formConnections',
    33                 'dependency' => array('field' => 'engagebayMapEnabled', 'values' => array(1)),
    34                 'fields' => array(
    35                     array(
    36                         'name' => 'fieldMap',
    37                         'label' => __('Map EngageBay Fields with Gravity Forms', 'engagebaygfaddon'),
    38                         'type' => 'field_map',
    39                         'field_map' => $this->eb_gf_engagebay_fields(),
    40                         'tooltip' => '<h6>' . __('Field Mapping', 'engagebaygfaddon') . '</h6>' . __('Map EngageBay Fields with Gravity Form Fields', 'engagebaygfaddon'),
    41                     ),
    42                     array(
    43                         'name' => 'tag',
    44                         'label' => __('Add Tag', 'engagebaygfaddon'),
    45                         'type' => 'text',
    46                         'tooltip' => '<h6>' . __('Add Tag', 'engagebaygfaddon') . '</h6>' . __('Add a tag to identify the contact in EngageBay which are coming from the Gravity forms', 'engagebaygfaddon'),
    47                     ),
    48                 ),
    49             ),
    50             array(
    51                 'name' => 'formConnections',
    52                 'fields' => array(
    53                     // This field isn't strictly necessary. If you don't include one then a generic update button will be generated for you.
    54                     array(
    55                         'type' => 'save',
    56                         'messages' => array(
    57                             'success' => __('Field Mapping is successfully updated.', 'engagebaygfaddon'),
    58                             'error' => __('Something went wrong. Please check the field mapping and try again.', 'engagebaygfaddon'),
    59                         ),
    60                     ),
    61                 ),
    62             ),
    63         );
    64     }
    65 
    66     public function eb_gf_engagebay_fields()
    67     {
    68         $fields = array();
    69         $engagebay_fields = $this->eb_gf_get_engagebay_system_fields();
    70         $engagebay_fields = array_merge($engagebay_fields, $this->eb_gf_get_engagebay_custom_fields());
    71 
    72         foreach ($engagebay_fields as $engagebay_field) {
    73             $fields[] = array(
    74                 'name' => $engagebay_field['name'],
    75                 'label' => $engagebay_field['label'],
    76                 'required' => $engagebay_field['is_required'],
    77                 'type' => $engagebay_field['type'],
    78                 'key_field' => array(),
    79                 'engagebay_field_type' => $engagebay_field['field_type'] ?? '',
    80                 'field_type' => array(
    81                     'name', 'radio', 'select', 'text', 'html', 'checkbox', 'hidden', 'textarea', 'number', 'date', 'email', 'phone', 'website', 'fileupload', 'time', 'multiselect', 'section', 'page', 'address', 'multicheckbox', 'SYSTEM_ADDRESS'
    82                 ),
    83                 'class' => 'x-small',
    84             );
    85         }
    86 
    87         return $fields;
    88     }
    89 
    90     private function eb_gf_get_engagebay_system_fields()
    91     {
    92         return array(
    93             array('name' => 'name', 'label' => __('First name', 'engagebaygfaddon'), 'is_required' => true, 'type' => 'SYSTEM'),
    94             array('name' => 'last_name', 'label' => __('Last name', 'engagebaygfaddon'), 'is_required' => false, 'type' => 'SYSTEM'),
    95             array('name' => 'company', 'label' => __('Company', 'engagebaygfaddon'), 'is_required' => false, 'type' => 'SYSTEM'),
    96             array('name' => 'email', 'label' => __('Email', 'engagebaygfaddon'), 'is_required' => false, 'type' => 'SYSTEM'),
    97             array('name' => 'phone', 'label' => __('Phone', 'engagebaygfaddon'), 'is_required' => false, 'type' => 'SYSTEM'),
    98             array('name' => 'country', 'label' => __('Country', 'engagebaygfaddon'), 'is_required' => false, 'type' => 'SYSTEM'),
    99             array('name' => 'address', 'label' => __('Address', 'engagebaygfaddon'), 'is_required' => false, 'type' => 'SYSTEM', 'field_type' => 'SYSTEM_ADDRESS'),
    100             array('name' => 'city', 'label' => __('City', 'engagebaygfaddon'), 'is_required' => false, 'type' => 'SYSTEM', 'field_type' => 'SYSTEM_ADDRESS'),
    101             array('name' => 'state', 'label' => __('State', 'engagebaygfaddon'), 'is_required' => false, 'type' => 'SYSTEM', 'field_type' => 'SYSTEM_ADDRESS'),
    102             array('name' => 'zip', 'label' => __('Zip', 'engagebaygfaddon'), 'is_required' => false, 'type' => 'SYSTEM', 'field_type' => 'SYSTEM_ADDRESS'),
    103         );
    104     }
    105 
    106     public function eb_gf_on_submit_form($entry, $form)
    107     {
    108         $engagebay_fields = $this->eb_gf_get_engagebay_fields();
    109         $form_entries = $this->eb_gf_get_form_entries($form, $entry);
    110         $contact_properties = $this->eb_gf_prepare_contact_properties($form_entries, $engagebay_fields);
    111         $email = $this->eb_gf_get_email_from_properties($contact_properties);
    112 
    113         if (empty($email)) {
    114             return;
    115         }
    116 
    117         $api_handler = new EngagebayGFAddonAPI();
    118         $engagebay_contact = $api_handler->search_contact($email);
    119         $tags = $this->eb_gf_prepare_tags($form);
    120 
    121         $payload = [
    122             'score' => 10,
    123             'properties' => $contact_properties,
    124             'tags' => $tags
    125         ];
    126 
    127         if ($engagebay_contact) {
    128             $payload['id'] = $engagebay_contact['id'];
    129             $api_handler->update_contact($payload);
    130         } else {
    131             $api_handler->add_contact($payload);
    132         }
    133     }
    134 
    135     private function eb_gf_get_engagebay_fields()
    136     {
    137         return array_merge($this->eb_gf_get_engagebay_system_fields(), $this->eb_gf_get_engagebay_custom_fields());
    138     }
    139 
    140     private function eb_gf_get_form_entries($form, $entry)
    141     {
    142         return $this->eb_gf_form_entries($form, $entry);
    143     }
    144 
    145     private function eb_gf_get_engagebay_custom_fields()
    146     {
    147         $engagebay_custom_fields = array();
    148         $api_handler = new EngagebayGFAddonAPI();
    149         $custom_fields = $api_handler->get_custom_fields();
    150 
    151         if ($custom_fields && is_array($custom_fields)) {
    152             foreach ($custom_fields as $custom_field) {
    153                 $engagebay_custom_fields[] = array(
    154                     'name' => $custom_field['field_name'],
    155                     'label' => $custom_field['field_label'],
    156                     'field_type' => $custom_field['field_type'],
    157                     'is_required' => (bool)$custom_field['is_required'],
    158                     'type' => 'CUSTOM',
    159                 );
    160             }
    161         }
    162 
    163         return $engagebay_custom_fields;
    164     }
    165 
    166     private function eb_gf_prepare_contact_properties($form_entries, $engagebay_fields)
    167     {
    168         $contact_properties = [];
    169         $fieldTypesMap = [
    170             'checkbox' => 'MULTICHECKBOX',
    171             'date' => 'DATE'
    172         ];
    173 
    174         foreach ($form_entries as $engagebay_field => $value) {
    175             $type = $this->eb_gf_get_field_type($engagebay_fields, $engagebay_field);
    176             if (strlen($type) === 0) {
    177                 continue;
    178             }
    179 
    180             $value = explode("***", $value);
    181 
    182             $contact_properties[] = [
    183                 'name' => $engagebay_field,
    184                 'value' => $value[1],
    185                 'field_type' => $fieldTypesMap[$value[0]] ?? 'TEXT',
    186                 'is_searchable' => isset($fieldTypesMap[$value[0]]) && $value[0] == 'checkbox',
    187                 'type' => $type
    188             ];
    189 
    190             if ($engagebay_field === "phone") {
    191                 $contact_properties[count($contact_properties) - 1]['subtype'] = 'work';
    192             }
    193         }
    194 
    195         return $contact_properties;
    196     }
    197 
    198     private function eb_gf_get_email_from_properties($contact_properties)
    199     {
    200         foreach ($contact_properties as $property) {
    201             if ($property['name'] === 'email') {
    202                 return $property['value'];
    203             }
    204         }
    205         return '';
    206     }
    207 
    208     private function eb_gf_prepare_tags($form)
    209     {
    210         $all_tags = $form['engagebay']['tag'];
    211         $split_tags = explode(",", $all_tags);
    212         return array_map(function ($tag) {
    213             return ['tag' => $tag];
    214         }, $split_tags);
    215     }
    216 
    217     private function eb_gf_get_field_type($fields, $name)
    218     {
    219         $filtered_fields = array_values(array_filter($fields, function ($field) use ($name) {
    220             return $field['name'] === $name;
    221         }));
    222 
    223         if (count($filtered_fields) > 0) {
    224             return $filtered_fields[0]['type'];
    225         }
    226 
    227         return '';
    228     }
    229 
    230     /**
    231      * @param $form
    232      * @param $entry
    233      * @return array
    234      */
    235     public function eb_gf_form_entries($form, $entry): array
    236     {
    237         $form_entries = [];
    238         foreach (EngageBayGFAddon::eb_gf_form_settings($form) as $key => $fieldId) {
    239             if (str_starts_with($key, 'fieldMap_') && !empty($fieldId)) {
    240                 $input_type = $this->eb_gf_input_type($form['fields'], $fieldId);
    241                 $key = substr($key, strlen('fieldMap_'));
    242                 $value = rgar($entry, $fieldId);
    243                 switch ($input_type) {
    244                     case 'checkbox':
    245                         $checkboxes = GFFormsModel::get_field($form, $form['engagebay']['fieldMap_' . $key]);
    246                         $checkbox_values = is_object($checkboxes) ? $checkboxes->get_value_export($entry) : '';
    247                         $checkbox_values = preg_replace('/,\s+/', ',', $checkbox_values);
    248                         $value = $checkbox_values;
    249                         break;
    250                     case 'date':
    251                         $value = strtotime( $value ) == '' ? '' : strtotime( $value );
    252                         break;
    253 
    254                 }
    255 
    256                 $form_entries[$key] = $input_type . '***' . $value;
    257             }
    258         }
    259 
    260         return $form_entries;
    261     }
    262 
    263     private function eb_gf_input_type($fields, $fieldId)
    264     {
    265         $filteredFields = array_values(array_filter($fields, function ($field) use ($fieldId) {
    266             return $field['id'] == $fieldId;
    267         }));
    268 
    269         if (count($filteredFields) > 0) {
    270             return $filteredFields[0]['type'];
    271         }
    272 
    273         return 'text';
    274     }
     3class EngageBayGFAddonFormHandler {
     4    public function eb_gf_add_actions() {
     5        add_action( 'gform_after_submission', array( $this, 'eb_gf_on_submit_form' ), 10, 2 );
     6    }
     7
     8    public function eb_gf_settings( $form ) {
     9        return array(
     10            array(
     11                'title'  => __( 'Gravity Form Field Mapping with EngageBay Fields', 'engagebaygfaddon' ),
     12                'fields' => array(
     13                    array(
     14                        'name'    => 'mapGravityFormsToEngagebay',
     15                        'label'   => __( 'Configuration', 'engagebaygfaddon' ),
     16                        'onclick' => "jQuery(this).parents('form').submit();",
     17                        'type'    => 'checkbox',
     18                        'choices' => array(
     19                            array(
     20                                'label' => sprintf( __( 'Integrate %s with EngageBay', 'engagebaygfaddon' ), $form['title'] ),
     21                                'name'  => 'engagebayMapEnabled',
     22                            ),
     23                        ),
     24                    ),
     25                ),
     26            ),
     27            array(
     28                'title'      => __( 'Fields Mapping', 'engagebaygfaddon' ),
     29                'name'       => 'formConnections',
     30                'dependency' => array( 'field' => 'engagebayMapEnabled', 'values' => array( 1 ) ),
     31                'fields'     => array(
     32                    array(
     33                        'name'      => 'fieldMap',
     34                        'label'     => __( 'Map EngageBay Fields with Gravity Forms', 'engagebaygfaddon' ),
     35                        'type'      => 'field_map',
     36                        'field_map' => $this->eb_gf_engagebay_fields(),
     37                        'tooltip'   => '<h6>' . __( 'Field Mapping', 'engagebaygfaddon' ) . '</h6>' . __( 'Map EngageBay Fields with Gravity Form Fields', 'engagebaygfaddon' ),
     38                    ),
     39                    array(
     40                        'name'    => 'tag',
     41                        'label'   => __( 'Add Tag', 'engagebaygfaddon' ),
     42                        'type'    => 'text',
     43                        'tooltip' => '<h6>' . __( 'Add Tag', 'engagebaygfaddon' ) . '</h6>' . __( 'Add a tag to identify the contact in EngageBay which are coming from the Gravity forms', 'engagebaygfaddon' ),
     44                    ),
     45                ),
     46            ),
     47            array(
     48                'name'   => 'formConnections',
     49                'fields' => array(
     50                    // This field isn't strictly necessary. If you don't include one then a generic update button will be generated for you.
     51                    array(
     52                        'type'     => 'save',
     53                        'messages' => array(
     54                            'success' => __( 'Field Mapping is successfully updated.', 'engagebaygfaddon' ),
     55                            'error'   => __( 'Something went wrong. Please check the field mapping and try again.', 'engagebaygfaddon' ),
     56                        ),
     57                    ),
     58                ),
     59            ),
     60        );
     61    }
     62
     63    public function eb_gf_engagebay_fields() {
     64        $fields           = array();
     65        $engagebay_fields = $this->eb_gf_get_engagebay_system_fields();
     66        $engagebay_fields = array_merge( $engagebay_fields, $this->eb_gf_get_engagebay_custom_fields() );
     67
     68        foreach ( $engagebay_fields as $engagebay_field ) {
     69            $fields[] = array(
     70                'name'                 => $engagebay_field['name'],
     71                'label'                => $engagebay_field['label'],
     72                'required'             => $engagebay_field['is_required'],
     73                'type'                 => $engagebay_field['type'],
     74                'key_field'            => array(),
     75                'engagebay_field_type' => $engagebay_field['field_type'] ?? '',
     76                'field_type'           => array(
     77                    'name',
     78                    'radio',
     79                    'select',
     80                    'text',
     81                    'html',
     82                    'checkbox',
     83                    'hidden',
     84                    'textarea',
     85                    'number',
     86                    'date',
     87                    'email',
     88                    'phone',
     89                    'website',
     90                    'fileupload',
     91                    'time',
     92                    'multiselect',
     93                    'section',
     94                    'page',
     95                    'address',
     96                    'multicheckbox',
     97                    'SYSTEM_ADDRESS'
     98                ),
     99                'class'                => 'x-small',
     100            );
     101        }
     102
     103        return $fields;
     104    }
     105
     106    private function eb_gf_get_engagebay_system_fields() {
     107        return array(
     108            array( 'name'        => 'name',
     109                   'label'       => __( 'First name', 'engagebaygfaddon' ),
     110                   'is_required' => true,
     111                   'type'        => 'SYSTEM'
     112            ),
     113            array( 'name'        => 'last_name',
     114                   'label'       => __( 'Last name', 'engagebaygfaddon' ),
     115                   'is_required' => false,
     116                   'type'        => 'SYSTEM'
     117            ),
     118            array( 'name'        => 'company',
     119                   'label'       => __( 'Company', 'engagebaygfaddon' ),
     120                   'is_required' => false,
     121                   'type'        => 'SYSTEM'
     122            ),
     123            array( 'name'        => 'email',
     124                   'label'       => __( 'Email', 'engagebaygfaddon' ),
     125                   'is_required' => false,
     126                   'type'        => 'SYSTEM'
     127            ),
     128            array( 'name'        => 'phone',
     129                   'label'       => __( 'Phone', 'engagebaygfaddon' ),
     130                   'is_required' => false,
     131                   'type'        => 'SYSTEM'
     132            ),
     133            array( 'name'        => 'country',
     134                   'label'       => __( 'Country', 'engagebaygfaddon' ),
     135                   'is_required' => false,
     136                   'type'        => 'SYSTEM'
     137            ),
     138            array( 'name'        => 'address',
     139                   'label'       => __( 'Address', 'engagebaygfaddon' ),
     140                   'is_required' => false,
     141                   'type'        => 'SYSTEM',
     142                   'field_type'  => 'SYSTEM_ADDRESS'
     143            ),
     144            array( 'name'        => 'city',
     145                   'label'       => __( 'City', 'engagebaygfaddon' ),
     146                   'is_required' => false,
     147                   'type'        => 'SYSTEM',
     148                   'field_type'  => 'SYSTEM_ADDRESS'
     149            ),
     150            array( 'name'        => 'state',
     151                   'label'       => __( 'State', 'engagebaygfaddon' ),
     152                   'is_required' => false,
     153                   'type'        => 'SYSTEM',
     154                   'field_type'  => 'SYSTEM_ADDRESS'
     155            ),
     156            array( 'name'        => 'zip',
     157                   'label'       => __( 'Zip', 'engagebaygfaddon' ),
     158                   'is_required' => false,
     159                   'type'        => 'SYSTEM',
     160                   'field_type'  => 'SYSTEM_ADDRESS'
     161            ),
     162        );
     163    }
     164
     165    public function eb_gf_on_submit_form( $entry, $form ) {
     166        $engagebay_fields   = $this->eb_gf_get_engagebay_fields();
     167        $form_entries       = $this->eb_gf_get_form_entries( $form, $entry );
     168        $contact_properties = $this->eb_gf_prepare_contact_properties( $form_entries, $engagebay_fields );
     169        $email              = $this->eb_gf_get_email_from_properties( $contact_properties );
     170
     171        if ( empty( $email ) ) {
     172            return;
     173        }
     174
     175        $api_handler       = new EngagebayGFAddonAPI();
     176        $engagebay_contact = $api_handler->search_contact( $email );
     177        $tags              = $this->eb_gf_prepare_tags( $form );
     178
     179        $payload = [
     180            'score'      => 10,
     181            'properties' => $contact_properties,
     182            'tags'       => $tags
     183        ];
     184
     185        if ( $engagebay_contact ) {
     186            $payload['id'] = $engagebay_contact['id'];
     187            $api_handler->update_contact( $payload );
     188        } else {
     189            $api_handler->add_contact( $payload );
     190        }
     191    }
     192
     193    private function eb_gf_get_engagebay_fields() {
     194        return array_merge( $this->eb_gf_get_engagebay_system_fields(), $this->eb_gf_get_engagebay_custom_fields() );
     195    }
     196
     197    private function eb_gf_get_form_entries( $form, $entry ) {
     198        return $this->eb_gf_form_entries( $form, $entry );
     199    }
     200
     201    private function eb_gf_get_engagebay_custom_fields() {
     202        $engagebay_custom_fields = array();
     203        $api_handler             = new EngagebayGFAddonAPI();
     204        $custom_fields           = $api_handler->get_custom_fields();
     205
     206        if ( $custom_fields && is_array( $custom_fields ) ) {
     207            foreach ( $custom_fields as $custom_field ) {
     208                $engagebay_custom_fields[] = array(
     209                    'name'        => $custom_field['field_name'],
     210                    'label'       => $custom_field['field_label'],
     211                    'field_type'  => $custom_field['field_type'],
     212                    'is_required' => (bool) $custom_field['is_required'],
     213                    'type'        => 'CUSTOM',
     214                );
     215            }
     216        }
     217
     218        return $engagebay_custom_fields;
     219    }
     220
     221    private function eb_gf_prepare_contact_properties( $form_entries, $engagebay_fields ) {
     222        $contact_properties = [];
     223        $fieldTypesMap      = [
     224            'checkbox' => 'MULTICHECKBOX',
     225            'date'     => 'DATE'
     226        ];
     227
     228        $address = [];
     229        foreach ( $form_entries as $engagebay_field => $value ) {
     230            $type = $this->eb_gf_get_field_type( $engagebay_fields, $engagebay_field );
     231            if ( strlen( $type ) === 0 ) {
     232                continue;
     233            }
     234
     235            $value = explode( "***", $value );
     236
     237            $contact_properties[] = [
     238                'name'          => $engagebay_field,
     239                'value'         => $value[1],
     240                'field_type'    => $fieldTypesMap[ $value[0] ] ?? 'TEXT',
     241                'is_searchable' => isset( $fieldTypesMap[ $value[0] ] ) && $value[0] == 'checkbox',
     242                'type'          => $type
     243            ];
     244
     245            if ( $engagebay_field === "phone" ) {
     246                $contact_properties[ count( $contact_properties ) - 1 ]['subtype'] = 'work';
     247            }
     248
     249            if ( $engagebay_field === 'address' ) {
     250                $address['address'] = $value[1];
     251            } else if ( $engagebay_field === 'city' ) {
     252                $address['city'] = $value[1];
     253            } else if ( $engagebay_field === 'state' ) {
     254                $address['state'] = $value[1];
     255            } else if ( $engagebay_field === 'country' ) {
     256                $address['country'] = $value[1];
     257            } else if ( $engagebay_field === 'zip' ) {
     258                $address['zip'] = $value[1];
     259            }
     260        }
     261
     262        return array_map( function ( $contact_property ) use ( $address ) {
     263            if ( $contact_property['name'] === 'address' ) {
     264                $contact_property['value'] = json_encode( $address );
     265            }
     266
     267            return $contact_property;
     268        }, $contact_properties );
     269    }
     270
     271    private function eb_gf_get_email_from_properties( $contact_properties ) {
     272        foreach ( $contact_properties as $property ) {
     273            if ( $property['name'] === 'email' ) {
     274                return $property['value'];
     275            }
     276        }
     277
     278        return '';
     279    }
     280
     281    private function eb_gf_prepare_tags( $form ) {
     282        $all_tags   = $form['engagebay']['tag'];
     283        $split_tags = explode( ",", $all_tags );
     284
     285        return array_map( function ( $tag ) {
     286            return [ 'tag' => $tag ];
     287        }, $split_tags );
     288    }
     289
     290    private function eb_gf_get_field_type( $fields, $name ) {
     291        $filtered_fields = array_values( array_filter( $fields, function ( $field ) use ( $name ) {
     292            return $field['name'] === $name;
     293        } ) );
     294
     295        if ( count( $filtered_fields ) > 0 ) {
     296            return $filtered_fields[0]['type'];
     297        }
     298
     299        return '';
     300    }
     301
     302    /**
     303     * @param $form
     304     * @param $entry
     305     *
     306     * @return array
     307     */
     308    public function eb_gf_form_entries( $form, $entry ): array {
     309        $form_entries = [];
     310        foreach ( EngageBayGFAddon::eb_gf_form_settings( $form ) as $key => $fieldId ) {
     311            if ( str_starts_with( $key, 'fieldMap_' ) && ! empty( $fieldId ) ) {
     312                $input_type = $this->eb_gf_input_type( $form['fields'], $fieldId );
     313                $key        = substr( $key, strlen( 'fieldMap_' ) );
     314                $value      = rgar( $entry, $fieldId );
     315                switch ( $input_type ) {
     316                    case 'checkbox':
     317                        $checkboxes      = GFFormsModel::get_field( $form, $form['engagebay'][ 'fieldMap_' . $key ] );
     318                        $checkbox_values = is_object( $checkboxes ) ? $checkboxes->get_value_export( $entry ) : '';
     319                        $checkbox_values = preg_replace( '/,\s+/', ',', $checkbox_values );
     320                        $value           = $checkbox_values;
     321                        break;
     322                    case 'date':
     323                        $value = strtotime( $value ) == '' ? '' : strtotime( $value );
     324                        break;
     325
     326                }
     327
     328                $form_entries[ $key ] = $input_type . '***' . $value;
     329            }
     330        }
     331
     332        return $form_entries;
     333    }
     334
     335    private function eb_gf_input_type( $fields, $fieldId ) {
     336        $filteredFields = array_values( array_filter( $fields, function ( $field ) use ( $fieldId ) {
     337            return $field['id'] == $fieldId;
     338        } ) );
     339
     340        if ( count( $filteredFields ) > 0 ) {
     341            return $filteredFields[0]['type'];
     342        }
     343
     344        return 'text';
     345    }
    275346}
  • engagebay-gravity-forms/trunk/readme.txt

    r3179179 r3297824  
    33Tags: gravity, forms, submit, submission, lead, api, gravity forms, form, contact form, contact form plugin, form builder, custom form, form creator, form manager, contact button, contact me, custom contact form, forms builder, mailchimp gravity forms, aweber gravity forms, campaign monitor, constant contact gravity forms, hubspot gravity forms, gravity forms salesforce, gravity forms salesforce add on, gravity forms salesforce crm, gravity forms salesforce integration, salesforce wordpress gravity forms, gravity form active campaign
    44Requires at least: 3.7
    5 Tested up to: 6.6.2
    6 Stable tag: trunk
     5Tested up to: 6.8.1
     6Stable tag: 3.1.4
    77
    88This plugin integrates Gravity Forms with EngageBay allowing form submissions to be automatically sent to user’s EngageBay account. Link any field type with EngageBay including custom fields.
     
    42421) Install the EngageBay Forms plugin
    4343
    44 Login to your WordPress admin panel, go to the 'Plugins' menu and click on 'Add New'. 
     44Login to your WordPress admin panel, go to the 'Plugins' menu and click on 'Add New'.
    4545
    46 - Search for 'EngageBay for Gravity forms' in the WordPress plugin repository and click 'Install Now'. Activate the plugin after installation. After activation, you will see the ‘EngageBay’ tab on your main menu. 
     46- Search for 'EngageBay for Gravity forms' in the WordPress plugin repository and click 'Install Now'. Activate the plugin after installation. After activation, you will see the ‘EngageBay’ tab on your main menu.
    4747
    48 - Download the EngageBay Gravity forms WordPress plugin from our website. Click ‘Upload Plugin’ to upload the plugin zip file and click 'Install Now'. Activate the plugin after installation. After activation, you will see the ‘EngageBay’ tab on your main menu. 
     48- Download the EngageBay Gravity forms WordPress plugin from our website. Click ‘Upload Plugin’ to upload the plugin zip file and click 'Install Now'. Activate the plugin after installation. After activation, you will see the ‘EngageBay’ tab on your main menu.
    4949
    50502) Create or set up EngageBay account
     
    9898== Changelog ==
    9999
    100 - Fixed tags issue when updating the existing contacts
     100- Fixed address field issue
Note: See TracChangeset for help on using the changeset viewer.