bookmark_bordergform_zapier_field_value

Description

This filter can be used to modify a value before it is sent to Zapier.

Usage

add_filter( 'gform_zapier_field_value', 'your_function_name', 10, 4 );

Parameters

  • $value string

    The value to be modified.

  • $form_id integer

    The ID of the form being processed.

  • $field_id string

    The ID of the field being processed.

  • $entry Entry Object

    The entry currently being processed.

Examples

1. Use GF_Field::get_value_export

This example shows how you can have the Zapier add-on use GF_Field::get_value_export() to format the field value for export. Requires a minimum of Gravity Forms 1.9.12.4.

add_filter( 'gform_zapier_field_value', 'format_entry_value', 10, 4 );
function format_entry_value( $value, $form_id, $field_id, $entry ) {
	$form  = GFAPI::get_form( $form_id );
	$field = GFFormsModel::get_field( $form, $field_id );

	if ( is_object( $field ) ) {
		$value = $field->get_value_export( $entry, $field_id, true );
	}

	return $value;
}

2. Change Signature Value

This example shows how you can send the url of the signature image.

add_filter( 'gform_zapier_field_value', 'change_signature_value', 10, 4 );
function change_signature_value( $value, $form_id, $field_id, $entry ) {
	$form  = GFAPI::get_form( $form_id );
	$field = GFFormsModel::get_field( $form, $field_id );

	if ( is_object( $field ) && $field->get_input_type() == 'signature' ) {
		$value = RGFormsModel::get_upload_url_root() . 'signatures/' . $value;
	}

	return $value;
}

3. Entry Meta

This example shows how you can override multiple field values and send entry meta instead, using the field’s default value as the key to the meta in the entry object. For example if the field’s default value was transaction_id then that entry meta value will be sent to Zapier for that field.

add_filter( 'gform_zapier_field_value', 'change_field_value', 10, 4 );
function change_field_value( $value, $form_id, $field_id, $entry ) {
    $fields = array( 5, 6, 7 );
	if ( in_array( $field_id, $fields ) && ! empty( $value ) ) {
		$value = rgar( $entry, $value );
	}

	return $value;
}

4. Format Date Field Value

This example shows how you can send the date field.

add_filter( 'gform_zapier_field_value', 'format_date_value', 10, 4 );
function format_date_value( $value, $form_id, $field_id, $entry ) {
	$form  = GFAPI::get_form( $form_id );
	$field = GFFormsModel::get_field( $form, $field_id );

	if ( is_object( $field ) && $field->get_input_type() == 'date' ) {
		$value = GFCommon::date_display( $value, $field->dateFormat );
	}

	return $value;
}

Placement

This code should be placed in the functions.php file of your active theme

Source Code

This filter is located in GFZapier::get_body() in zapier.php