Skip Navigation

[Resolved] iframe gets lost when saving

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

Problem:

The issue here is that the custom was trying to add an IFRAME to a WYSIWYG field on a CRED form but when the customer saves the form the IFRAME isn't saved.

Solution:

The reason for this is that the iframe isn't in the allowed tags in CRED.

To add an iframe to the allowed tags add the following to your functions.php file

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,
);
return $allowedposttags;
}

Then go to Toolset -> Settings -> Forms ->Content Filter and click "Select allowed HTML Tags" and ensure that iframe is ticked.

This support ticket is created 6 years, 9 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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 8 replies, has 2 voices.

Last updated by a.R 6 years, 9 months ago.

Assisted by: Shane.

Author
Posts
#611700

a.R

I am trying to: save a page with an iframe

Link to a page where the issue can be seen:

I expected to see: the iframe in the post

Instead, I got: no iframe

#611863

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hello,

Thank you for contacting our support forum.

Could you let me know where you are placing the iframe if its in a custom field ?

Thanks,
Shane

#612003

a.R

No, it´s in the post body.

#612004

a.R

Ex: <iframe src="hidden link" width="100%" height="600" scrolling="no" allowfullscreen></iframe>

Besides that, the posts will not be found by custom search, although they are displayed in the menu etc.

#612258

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hello,

WOuld you mind providing me with admin access to the website and then walk me through the steps to replicate?

I have an Idea of what could be causing this but I would need to look to confirm.

The private fields have been enabled for your next response.

Thanks,
Shane

#612870

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hello,

Send me a link to the page where you added the iframe, Also what I meant by walkthrough is to just let me know the exact steps you did to add the iframe.

Thanks,
Shane

#613177

a.R

Hi 🙂

It´s e.g. on the page
hidden link

I copied the link

<iframe src="<em><u>hidden link</u></em>" width="100%" height="600" scrolling="no" allowfullscreen></iframe>

from the PhET-Website using the CRED-Form
hidden link

Thank you, regards, Achim

#613401

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Achim,

I was able to replicate the issue. It seems the problem is that Iframes are not allowed. To allow the iframe I would like for you to add this to your functions.php file

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,
);
return $allowedposttags;
}

Then go to Toolset -> Settings -> Forms ->Content Filter and click "Select allowed HTML Tags" and ensure that iframe is ticked.

Please let me know if this helps.
Thanks,
Shane

#613428

a.R

Done, works fine.

THANK YOU

Regards, Achim