gform_currency_pre_save_entry

Description

This filter can be used to override the default currency code before the entry is saved.

Usage

The base filter which would run for all forms would be used like so:

add_filter( 'gform_currency_pre_save_entry', 'your_function_name', 10, 2 );

To target a specific form append the form id to the hook name. (format: gform_currency_pre_save_entry_FORMID)

add_filter( 'gform_currency_pre_save_entry_5', 'your_function_name', 10, 2 );

Parameters

  • $currency string

    The three character ISO currency code to be stored in the entry. Default is value returned by GFCommon::get_currency()

  • $form Form Object

    The form currently being processed.

Example

This example shows how you can override the currency code with a value from a form field.

add_filter( 'gform_currency_pre_save_entry', 'override_currency_code', 10, 2 );
function override_currency_code( $currency, $form ) {

return rgpost( 'input_7' );
}

Placement

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

Source Code

gf_apply_filters( 'gform_currency_pre_save_entry', $form['id'], GFCommon::get_currency(), $form )

This filter is located in GFFormsModel::create_lead and GFFormsModel::save_lead in forms_model.php.

Since

This filter was added in Gravity Forms 1.9.13.26.