Skip Navigation

[Resolved] iframe not saving in form data

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

Problem:

A Toolset Form was used to save an iframe embed code into a custom field (event-map) using [cred_field ...], but the iframe was being stripped from the submitted content and not saved. The user had already tried allowing iframe via the wp_kses_allowed_html filter, but it still didn’t persist. The behavior had worked previously and later stopped.

Solution:

Enable iframe support in Toolset’s own Forms Content Filter so Toolset Forms stops stripping the tag:

Go to Toolset → Settings → Forms → Content Filter

Click “Select allowed HTML tags”

Enable iframe and save

Also ensure the embed code is stored in a Multiple Lines (or WYSIWYG) field rather than a Single Line field to prevent truncation/format issues.

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.

This topic contains 1 reply, has 1 voice.

Last updated by terryE 5 days, 11 hours ago.

Assisted by: Christopher Amirian.

Author
Posts
#2840003

I am trying to save an iframe using a form. Data is multi-lines, same as other websites I have using same data.

Form data
[cred_field field="event-map" force_type="field" class="form-control" output="bootstrap"]

I have this from another site...

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

function esw_author_cap_filter( $allowedposttags ) {

//Here put your conditions, depending your context

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,
'allowfullscreen' => true,
'loading' => true,
'referrerpolicy' => true,
);
return $allowedposttags;
}

But it is not saving the data and the iframe is being stripped out.

It was working a few weeks ago, not sure if connected, but noticed stopped working after this update (just fyi)
https://toolset.com/forums/topic/json-input-into-checkboxes-cred_generic_field-on-a-form/

#2840085

Christopher Amirian
Supporter

Languages: English (English )

Hi,

Welcome to Toolset support.

Toolset Forms strips <iframe> unless you allow it in Toolset’s Forms Content Filter.

- Go to Toolset → Settings → Forms → Content Filter
-Click “Select allowed HTML tags”
- Enable iframe and save

Store the embed code in a Multiple Lines (or WYSIWYG) field, not a Single Line, to avoid truncation/format issues.

For more information:
https://toolset.com/forums/topic/submit-iframe-code-in-forms/

Thanks.

#2840152

I know of that, no idea why I missed that - Might be as iframe appears at the end perhaps 🤔

Sorted anyway - thanks for your help 😊