gcgs_row_value

  1. Description
  2. Usage
  3. Parameters
  4. Examples
    1. Send numeric values as strings
  5. Since

Description

Filter a value before it gets inserted into a row in Google Sheets.

Usage

Filter all values before they get inserted into Google Sheets.

add_filter( 'gcgs_row_value', 'my_custom_function' );

Filter values in a form before they get inserted into Google Sheets.

add_filter( 'gcgs_row_value_FORMID', 'my_custom_function' );

Filter a specific field’s value before it gets inserted into Google Sheets.

add_filter( 'gcgs_row_value_FORMID_FIELDID', 'my_custom_function' );

Parameters

  • value mixed

    The value to be inserted.

  • form_id int

    The current form ID.

  • field_id string

    The current field ID.

  • entry array

    The current entry.

  • original_value mixed

    The original value before any filters were applied.

Examples

Send numeric values as strings

This snippet will forcefully send values as a string which can eliminate issues where numbers with preceding 0’s are removed (e.g. postal codes).

<?php
/**
 * Gravity Connect // Google Sheets // Force field value to be added to the sheet as a string
 *
 * In some situations, there may be numbers that have leading 0's, such as zip codes. By default, these will be converted
 * to numbers in Google Sheets and the leading 0's will be removed.
 *
 * This snippet casts the value to a string before it is sent to Google Sheets, which will preserve the leading 0's.
 *
 * Installation:
 *   1. Install per https://gravitywiz.com/documentation/how-do-i-install-a-snippet/
 *   2. Update the FORMID and FIELDID accordingly.
 */
add_filter( 'gcgs_row_value_FORMID_FIELDID', function( $value, $form_id, $field_id, $entry, $original_value ) {
	return (string) $original_value;
}, 10, 5 );

Since

This filter is available since Gravity Forms Google Sheets 1.0-beta-1.10.