gform_other_choice_value

Description

Use this filter to change the default “Other” text on Radio Button fields.

Usage

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

Parameters

  • $value string

    The default value of the “Other” choice input.

  • $field null | GF_Field

    Null or the Field currently being prepared for display or being validated.

Examples

This example changes the text to “Enter your own value” for all fields.

add_filter( 'gform_other_choice_value', function( $value, $field ) {
    return 'Enter your own value';
}, 10, 2 );

This example changes the text to “My Custom Text” only for a field with id 6 that is added to a form that has id 25.

add_filter( 'gform_other_choice_value', 'set_other_choice_value', 10, 2 );
function set_other_choice_value( $value, $field ) {
	if ( is_object( $field ) && 6 === $field->id && 25 === $field->formId ){ // 6 and 25 to your field id and form id number.
		$value = 'My Custom Text';
	}
	return $value;
}

Placement

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

Since

The $field parameter was added in 2.1.1.6.

Source Code

This filter is located in GFCommon::get_other_choice_value() in common.php.