Support » Plugin: Forminator - Contact Form, Payment Form & Custom Form Builder » All custom html stripped from response

  • Resolved rsmith4321

    (@rsmith4321)


    I’ve had some forms setup that in the response to submission used customs tags like <h2> <table> etc. It’s worked great until I recently tried to edit one. Now everything is being stripped except for the <p> tags. I read a support doc that seemed to be my issue. I tried the following but it’s not working. Is there any way to allow all custom html in a form response? This has really messed me up. Thanks!

    add_filter( 'forminator_change_form_allowed_html', function( $allowed_html ){
    	$allowed_html[ 'h3, h2, h1, img, td, tbody, table, hr, div' ] = array();
    	return $allowed_html;
    } );
Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Support Nithin – WPMU DEV Support

    (@wpmudevsupport11)

    Hi @rsmith4321,

    Please try the following code and see how it goes:

    add_filter( 'forminator_change_form_allowed_html', function( $allowed_html ){
    	
    	$allowed_html = array(
    	
    			'h1' => array(),
    			'h2' => array(),
    			'h3' => array(),
    			'td' => array(),
    	);
    	
    	
    	return $allowed_html;
    } );

    You can add new HTML tags in the above format as the next line. Once the code is added you’ll have to re-add the HTML tags in the After Submission message, so that it would get saved correctly.

    Please do let us know how that goes. Have a nice day ahead.

    Kind Regards,
    Nithin

    Thread Starter rsmith4321

    (@rsmith4321)

    Thanks, that does work better, I changed it to this

    add_filter( 'forminator_change_form_allowed_html', function( $allowed_html ){
    	
    	$allowed_html = array(
    	
    			'h1' => array(),
    			'h2' => array(),
    			'h3' => array(),
    			'td' => array(),
    			'tr' => array(),
    			'tbody' => array(),
    			'table' => array(),
    			'span' => array(),
    			'img' => array(),
    			'div' => array(),
    	);
    	
    	
    	return $allowed_html;
    } );

    However it still seems to strip any styles and classes from the <div> tags as well as <span> tags. Do you have any suggestions? Also, is it correct to have a comma after the last item in the array? Thanks.

    • This reply was modified 1 year, 9 months ago by rsmith4321.
    • This reply was modified 1 year, 9 months ago by rsmith4321.
    Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @rsmith4321

    I was able to replicate this on my lab site.

    We pinged the plugin developers and will let you know once hearing back from the team.

    Best Regards
    Patrick Freitas

    Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @rsmith4321

    I hope you are doing well.

    Can you please try this code?

    <?php
    
    add_filter( 'forminator_change_form_allowed_html', function( $allowed_html ){
    
    	$allowed_html = array(
    
    			'h1' => array(),
    			'h2' => array(),
    			'h3' => array(),
    			'td' => array(),
    			'tr' => array(),
    			'tbody' => array(),
    			'table' => array(),
    			'span' => array(
    				'style' => true,
    				'class'	=> true,
    			),
    			'img' => array(),
    			'div' => array(
    				'style' => true,
    				'class'	=> true,
    			),
    	);
    	return $allowed_html;
    } );

    Best Regards
    Patrick Freitas

    Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @rsmith4321

    I hope you are doing well and safe!

    We haven’t heard from you in a while, I’ll mark this thread as resolved.

    Feel free to let us know if you have any additional question or problem.

    Best Regards
    Patrick Freitas

    Thread Starter rsmith4321

    (@rsmith4321)

    I finally had a chance to try the latest code. It’s still removing my tags and for some reason adding in a tag in it’s place. I really with there was a way just to disable filtering like the older versions, but if you have any other ideas I’ll try it. It’s finally not stripping the style tags with the latest version. Thanks.

    Thread Starter rsmith4321

    (@rsmith4321)

    I still haven’t been able to get this issue resolved, do you have any other ideas I can try to return the original functionality without stripping tags? Thanks!

    Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @rsmith4321

    From my tests, the code worked.

    Can you send the HTML that you are using and we can add it on our end and run a test to verify which ones are being removed?

    Best Regards
    Patrick Freitas

    Thread Starter rsmith4321

    (@rsmith4321)

    Thanks, I’m using the following tags like below, just real basic html with of course styles and classes inside the quotes and content in between.
    <div style="" class=""></div> <h2 style=""></h2> <br/> <p></p> <b></b> <img style="" class=""> <table style=""><tbody><tr><td style=""></td></tr></tbody></table>

    Thanks for the help.

    Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @rsmith4321

    Sorry for the delay,

    I tested it but seems forgot to update the ticket.

    I was able to replicate using this HTML, I found we implemented some extra tags but others still being removed.

    I sent this to our developers to verify why the filter isn’t working.

    We will update once hearing back from the team.
    Best Regards
    Patrick Freitas

    Plugin Support Kasia – WPMU DEV Support

    (@wpmudev-support2)

    Hello @rsmith4321 ,

    This issue will be fixed in 1.14.12 version of the plugin, please make sure to update plugin when new version will be released.

    kind regards,
    Kasia

    Thread Starter rsmith4321

    (@rsmith4321)

    When you say resolved do you mean I no longer need the code in my functions.php? Or just that it will work now with the code. What is the final recommendation for what I should add to my functions.php to get this working if it’s still needed?

    Plugin Support Nithin – WPMU DEV Support

    (@wpmudevsupport11)

    Hi @rsmith4321,

    At the moment, the tags will get stripped with the current solution used and I’m afraid there isn’t a workaround that could be suggested at the moment other than using one single HTML tags rather than multiple HTML tags.

    This issue is more within the plugin side and this behaviour will be changed in the next plugin release ie v 1.14.12, so that the existing code suggested before would work out of the box.

    At the moment, I’m afraid there isn’t any exact ETA that we could share regarding when the release would be made available. Hoping it would be soon.

    Kind Regards,
    Nithin

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘All custom html stripped from response’ is closed to new replies.