Using Gravity Forms ‘gform_rich_text_editor_buttons_row_two’ PHP filter

The gform_rich_text_editor_buttons_row_two filter in Gravity Forms allows you to customize the buttons displayed in the second row of the rich text editor within Gravity Forms.

Usage

add_filter('gform_rich_text_editor_buttons_row_two', 'my_function', 10, 2);
function my_function($mce_buttons, $editor_id) {
    // your custom code here
    return $mce_buttons;
}

Parameters

  • $mce_buttons (array): An array of second-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_two

Examples

Add a button to the second row of the rich text editor

add_filter('gform_rich_text_editor_buttons_row_two', 'add_custom_button', 10, 2);
function add_custom_button($mce_buttons, $editor_id) {
    $mce_buttons[] = 'my_custom_button';
    return $mce_buttons;
}

Remove a button from the second row of the rich text editor

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

Rearrange buttons in the second row of the rich text editor

add_filter('gform_rich_text_editor_buttons_row_two', 'rearrange_buttons', 10, 2);
function rearrange_buttons($mce_buttons, $editor_id) {
    $new_mce_buttons = array('undo', 'redo', 'outdent', 'indent', 'hr', 'forecolor', 'strikethrough', 'pastetext', 'removeformat', 'charmap', 'wp_help');
    return $new_mce_buttons;
}

Customize buttons for a specific form

add_filter('gform_rich_text_editor_buttons_row_two_2', 'customize_specific_form', 10, 2);
function customize_specific_form($mce_buttons, $editor_id) {
    $mce_buttons[] = 'my_custom_button';
    return $mce_buttons;
}

Customize buttons for a specific field in a specific form

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