How to stop script tags being removed from Gravity Forms HTML fields

If you are trying to insert a piece of Javascript code in Gravity Forms HTML fields but the script tag gets removed when you update your form, then this tutorials will help you fix this problem by just adding a few line of code to your functions.php file.

Why the script tag gets removed

By default WordPress’s TinyMCE Editor will remove the <script> tags. But you can overwrite the default settings by just adding the below code to your functions.php file.


function allow_script_tags( $allowedposttags ){
    $allowedposttags['script'] = array(
        'type' => true,
        'src' => true,
        'height' => true,
        'width' => true,
    );   
    return $allowedposttags;
}
add_filter('wp_kses_allowed_html','allow_script_tags', 1);
 

Paste the above code to your functions.php and updated your page.  Now go to Gravity Form, you should be able to insert Javascript code and the <script> tags will not get removed when you update your form.

Thanks.

Powered by WordPress. Designed by Woo Themes