Exclude Gravity Forms Notifications from Classic Editor WYSIWYG [RESOLVED]

Hello! I have a Gravity Forms notification that requires some custom HTML. To make it render properly, I have to use the text editor, disable auto formatting, and paste in the HTML that I’ve written in a separate application. That works fine.

Unfortunately, I need to use the regular Classic Editor WYSIWYG (visual, not text) mode for 99% of the site’s pages, posts, and other content. When I switch the editor back to visual mode, all of the HTML that I pasted into the notification is overwritten. All of the extra formatting, such as paragraph openings and closings, line breaks, and so forth gets wiped out. This is annoying and I must re-paste the HTML into the notification every time.

There has to be a better way – or, at least, I surely hope that there is. Does anyone have suggestions for preventing my custom HTML from getting wiped out every time I want to use the visual (WYSIWYG) editor? Thanks for any ideas!

You can disable the visual tab when in the notification/confirmation editor page by adding the following PHP snippet your site:

// remove visual editor tab from notification/confirmation editor screen
add_action( 'admin_init', 'disable_tinymce_in_gf'); 

function disable_tinymce_in_gf() {
 if ( ( RGForms::is_gravity_page() && rgget( 'page' ) == 'gf_edit_forms' && rgget( 'view' ) == 'settings' ) && ( rgget( 'subview' ) == 'notification' || rgget( 'subview' ) == 'confirmation' ) )  {
  add_filter( 'user_can_richedit', '__return_false' );
 }
}

If you want to limit it only to notifications, remove the || rgget( ‘subview’ ) == ‘confirmation’ part from the snippet.

2 Likes

Thank you very much, Samuel! This works perfectly. I really appreciate your help.

1 Like
© 2008 - 2021. Gravity Forms is a project by Rocketgenius Inc.