Using Gravity Forms ‘gform_rich_text_editor_buttons_row_four’ PHP filter

The gform_rich_text_editor_buttons_row_four filter in Gravity Forms allows you to customize the buttons displayed in the fourth row of the rich text editor. Note that by default, WordPress and Gravity Forms do not include any buttons on the fourth row of the rich text editor.

Usage

To apply the filter to all forms:

add_filter('gform_rich_text_editor_buttons_row_four', 'my_function', 10, 2);

To target a specific form, append the form ID to the hook name:

add_filter('gform_rich_text_editor_buttons_row_four_2', 'my_function', 10, 2);

To target a specific form field, append the form ID and field ID to the hook name:

add_filter('gform_rich_text_editor_buttons_row_four_2_6', 'my_function', 10, 2);

Parameters

  • $mce_buttons (array) – An array (empty by default) of fourth row buttons to include within the TinyMCE editor inside Gravity Forms.
  • $editor_id (string) – The HTML element ID for the field using the rich text editor.
  • $field_object (object) – Object containing information about the field.

More information

See Gravity Forms Docs: gform_rich_text_editor_buttons_row_four

Examples

Add a custom button to the fourth row

This example adds a custom button called ‘my_button’ to the fourth row of the rich text editor.

function add_my_custom_button($mce_buttons, $editor_id) {
    $mce_buttons[] = 'my_button';
    return $mce_buttons;
}
add_filter('gform_rich_text_editor_buttons_row_four', 'add_my_custom_button', 10, 2);

Add multiple buttons to the fourth row

This example adds two custom buttons ‘button_one’ and ‘button_two’ to the fourth row of the rich text editor.

function add_multiple_custom_buttons($mce_buttons, $editor_id) {
    array_push($mce_buttons, 'button_one', 'button_two');
    return $mce_buttons;
}
add_filter('gform_rich_text_editor_buttons_row_four', 'add_multiple_custom_buttons', 10, 2);

Remove a button from the fourth row

This example removes a button called ‘remove_button’ from the fourth row of the rich text editor.

function remove_specific_button($mce_buttons, $editor_id) {
    if (($key = array_search('remove_button', $mce_buttons)) !== false) {
        unset($mce_buttons[$key]);
    }
    return $mce_buttons;
}
add_filter('gform_rich_text_editor_buttons_row_four', 'remove_specific_button', 10, 2);

Add a custom button to a specific form

This example adds a custom button ‘specific_form_button’ to the fourth row of the rich text editor for form ID 2.

function add_button_to_specific_form($mce_buttons, $editor_id) {
    $mce_buttons[] = 'specific_form_button';
    return $mce_buttons;
}
add_filter('gform_rich_text_editor_buttons_row_four_2', 'add_button_to_specific_form', 10, 2);

Add a custom button to a specific form field

This example adds a custom button ‘specific_field_button’ to the fourth row of the rich text editor for