bookmark_bordergform_user_registration_prepared_value

Description

This filter can be used to modify a field value before it is saved to the user meta.

Usage

add_filter( 'gform_user_registration_prepared_value', 'your_function_name', 10, 5 );

Parameters

  • $value string

    The value to be modified.

  • $field Field Object

    The field currently being processed.

  • $input_id string

    The ID of the field input currently being processed.

  • $entry Entry Object

    The entry currently being processed.

  • $is_username bool

    Indicates if the current field is mapped to the username.

Examples

The following example shows how you can replace the address field country value with the country code.

add_filter( 'gform_user_registration_prepared_value', function ( $value, $field, $input_id, $entry, $is_username ) {
    $country_id = $field->id . '.6';
    if ( $field->type == 'address' && $input_id == $country_id ) {
        return GF_Fields::get( 'address' )->get_country_code( $value );
    }
    return $value;
}, 10, 5 );

Placement

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

Since

This filter was added in version 2.1

Source Code

$value = apply_filters( 'gform_user_registration_prepared_value', $value, $field, $input_id, $entry, $is_username );

This filter is located in GF_User_Registration::get_prepared_value() in class-gf-user-registration.php