Accessing Mapped Field Values During Feed Processing

Introduction

The following functions are located in the GFAddon class; they are also available for use by add-ons which extend the GFFeedAddOn or GFPaymentAddOn classes and can be used to retrieve the mapped form field values during feed processing in the process_feed() method.

get_mapped_field_value()

protected function get_mapped_field_value( $setting_name, $form, $entry, $settings = false ) {}

Source: Inline Documentation

Parameters

Returns

(string) The value of the mapped field.

Uses

Usage Example

$value = $this->get_mapped_field_value( $meta_key, $form, $entry, $feed['meta'] );

get_field_value()

public function get_field_value( $form, $entry, $field_id ) {}

Source: Inline Documentation

Parameters

  • $form Form Object

    The Form currently being processed.

  • $entry Entry Object

    The Entry currently being processed.

  • $field_id string

    The ID of the Field currently being processed.

Returns

(string) The value of the specified field.

Uses

Hooks

This function contains the following hooks:

Usage Example

$email = $this->get_field_value( $form, $entry, rgar( $feed['meta'], 'customerInformation_email' ) );

maybe_override_field_value()

public function maybe_override_field_value( $field_value, $form, $entry, $field_id ) {}

Override this function to prevent the gform_short_slug_field_value filter being used if you need to implement a custom filter, or need to perform custom formatting of some field types.

Source: Inline Documentation

Parameters

  • $field_value string

    The value to be overridden.

  • $form Form Object

    The Form currently being processed.

  • $entry Entry Object

    The Entry currently being processed.

  • $field_id string

    The ID of the Field currently being processed.

Returns

(string) The field value.

Hooks

This function contains the following hooks:

Usage Example

$coupon_field_id = rgar( $feed['meta'], 'customerInformation_coupon' );
$coupon          = $this->maybe_override_field_value( rgar( $entry, $coupon_field_id ), $form, $entry, $coupon_field_id );

get_full_address()

protected function get_full_address( $entry, $field_id ) {}

Override this function if your add-on needs to reformat the Address field value.

Source: Inline Documentation

Parameters

  • $entry Entry Object

    The Entry currently being processed.

  • $field_id string

    The ID of the Field currently being processed.

Returns

(string) Returns the combined value of the specified Address field.

get_full_name()

protected function get_full_name( $entry, $field_id ) {}

Override this function if your add-on needs to reformat the Name field value.

Source: Inline Documentation

Parameters

  • $entry Entry Object

    The Entry currently being processed.

  • $field_id string

    The ID of the Field currently being processed.

Returns

(string) Returns the combined value of the specified Name field.

get_list_field_value()

protected function get_list_field_value( $entry, $field_id, $field ) {}

Override this function if your add-on needs to reformat the List field value.

Source: Inline Documentation

Parameters

  • $entry Entry Object

    The Entry currently being processed.

  • $field_id string

    The ID of the Field currently being processed.

  • $field Field Object

    The Field currently being processed.

Returns

(string) Returns the formatted value of the specified List field or List field column.

get_{$input_type}_field_value()

To perform custom formatting of values for a specific field or input type you can define a custom function to be used when the get_field_value() processes that field type. Just replace {$input_type} in the function name with the field type you want to format e.g.

public function get_phone_field_value( $entry, $field_id, $field ) {
    $field_value = rgar( $entry, $field_id );
    if ( ! empty( $field_value ) && $field->phoneFormat == 'standard' && preg_match( '/^D?(d{3})D?D?(d{3})D?(d{4})$/', $field_value, $matches ) ) {
        $field_value = sprintf( '%s-%s-%s', $matches[1], $matches[2], $matches[3] );
    }

    return $field_value;
}