Skip Navigation

[Resolved] Submit iframe code in Forms

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to add an HTML iframe tag to a custom field when editing a post in a front-end Form, but the content does not seem to be saved. If I add the same code in wp-admin when editing a post, it is saved as expected.

Solution: For security purposes, Forms automatically restricts certain code. To override that security feature, you must enable iframe tags with custom code. Add the following custom code in your child theme's functions.php file:

add_filter( 'wp_kses_allowed_html', 'tssupp_author_cap_filter',1,1 );
 
function tssupp_author_cap_filter( $allowedposttags ) {
if ( !current_user_can( 'publish_posts' ) )
return $allowedposttags;
 
// Here add tags and attributes you want to allow
$allowedposttags['iframe']=array(
 
'align' => true,
'width' => true,
'height' => true,
'frameborder' => true,
'name' => true,
'src' => true,
'id' => true,
'class' => true,
'style' => true,
'scrolling' => true,
'marginwidth' => true,
'marginheight' => true,
);
return $allowedposttags;
}

That should cover most of the default iframe attributes for a Google Calendar embed, but you may need to adjust this code to support other non-default attributes individually.

Go to Toolset > Settings > Forms and click "Select allowed HTML tags". Choose all the tags you would like to allow Users to insert in a Form, including iframe tags.

This support ticket is created 3 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Author
Posts
#1937065

Thank you Chris
I had to uninstall and install. Don't know what happened but now it is showing.

now, I have a form for subscribers to send their info for my to display in my subscriber only account. there is a field for the subscriber to submit an iframe code.
But there is no way for the form to send the code. By no way I mean, the form custom field exists, but when the code is imput and submitted, it gets blank in the air, and it comes blank on the other end. I tried wysig, line,

If I go to the post type and input from the admin dashboard it shows ok in the page but I needed the functionality for the subscriber to submit the code (their public google calendar) through a form so they could post in their onw account.

Can you help me with this or I needed to open a new ticket?
Thanks

#1937085

I have a form for subscribers to send their info for my to display in my subscriber only account. there is a field for the subscriber to submit an iframe code.
But there is no way for the form to send the code. By no way I mean, the form custom field exists, but when the code is imput and submitted, it gets blank in the air, and it comes blank on the other end. I tried wysig, line,

If I go to the post type and input from the admin dashboard it shows ok in the page but I needed the functionality for the subscriber to submit the code (their public google calendar) through a form so their code (iframe) could post in their onw account. for just them to see it.
The toolset forms are working perfect. I can add videos, data, but not code or <iframe>. Thanks

#1937269

Hello, Toolset Forms restricts certain content types for security purposes. Iframes are a security risk, and they are not supported by default. If you'd like to override those security measures and allow iframe submissions in custom fields, there are two steps involved:
1. Add the following custom code in your child theme's functions.php file:

add_filter( 'wp_kses_allowed_html', 'tssupp_author_cap_filter',1,1 );

function tssupp_author_cap_filter( $allowedposttags ) {
if ( !current_user_can( 'publish_posts' ) )
return $allowedposttags;

// Here add tags and attributes you want to allow
$allowedposttags['iframe']=array(

'align' => true,
'width' => true,
'height' => true,
'frameborder' => true,
'name' => true,
'src' => true,
'id' => true,
'class' => true,
'style' => true,
'scrolling' => true,
'marginwidth' => true,
'marginheight' => true,
);
return $allowedposttags;
}

That should cover most of the default iframe attributes for a Google Calendar embed, but you may need to adjust this code to support other non-default attributes individually.

2. Go to Toolset > Settings > Forms and click "Select allowed HTML tags". Choose all the tags you would like to allow Users to insert in a Form, including iframe tags.

That's it, your Forms should support iframe tags now. For best results, I recommend using a Multiple Lines custom field to store iframe HTML tags and other HTML content.

#1941439

My issue is resolved now. Thank you!