gform_rich_text_editor_options

Description

The gform_rich_text_editor_options filter allows developers to modify the rich text editor options. A specific FORMID or FORMID + FIELDID may also be used with the hook.

Usage

Applies to all forms.

add_filter( 'gform_rich_text_editor_options', 'my_function', 10, 4 );

Targets a specific form.

add_filter( 'gform_rich_text_editor_options_3', 'my_function', 10, 4 );

Targets a specific field for a specific form.

add_filter( 'gform_rich_text_editor_options_3_6', 'my_function', 10, 4 );

Parameters

ParameterTypeDescription
$editor_settingsarrayArray of settings for the TinyMCE editor inside Gravity Forms.
$field_objectobjectThe full field object returned.
$formarrayThe form that the filter is being run on.
$entryarrayThe entry, if available.

$editor_settings defaults to the following:

array(
	'textarea_name' => 'input_' . $id,
	'wpautop'       => true,
	'editor_class'  => $class,
	'textarea_rows' => 10,
	'tabindex'      => $tabindex,
	'media_buttons' => false,
	'quicktags'     => false,
	'tinymce'       => array( 'init_instance_callback' => 'function...' ),
);

Examples

Set a custom height value.

function my_function( $editor_settings, $field_object, $form, $entry ) {
	$editor_settings['editor_height'] = 400;
	return $editor_settings;
}
add_filter( 'gform_rich_text_editor_options', 'my_function', 10, 4 );

Enable the Add Media button.

This will add the Add Media button before the toolbar just like WP does in Post/Page editor. The user must be logged in to see the button; this is a WordPress requirement not a Gravity Forms limitation.

function show_media_button( $editor_settings, $field_object, $form, $entry ) {
	$editor_settings['media_buttons'] = true;
	return $editor_settings;
}
add_filter( 'gform_rich_text_editor_options', 'show_media_button', 10, 4 );

Placement

This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.

See also the PHP section in this article: Where Do I Put This Code?

Source Code

This filter is located in class-gf-field-textarea.php.