Skip to content

Instantly share code, notes, and snippets.

@adczk
Created January 28, 2022 14:51
Show Gist options
  • Save adczk/51089242b79c84be74eaf0d386ec6eb3 to your computer and use it in GitHub Desktop.
Save adczk/51089242b79c84be74eaf0d386ec6eb3 to your computer and use it in GitHub Desktop.
Forminator 1.15.10 - include iframe in thank you message
<?php
/**
*
* Includes specified iframe in inline thank you message;
* note that it's quite "rough" and disables some sanitization
*
* by Adam/Panos/WPMU DEV
*
* use as MU plugin
*
* Tested with Forminato 1.15.10 only - no promises for other versions
*
* To configure, see comments in code
*
**/
add_filter(
'forminator_custom_form_thankyou_message',
function( $message, $submitted_data, $custom_form ) {
$form_id = 13376; // SET FORM ID HERE; iframe will be injected to this form thank you message only
if ( $form_id == $custom_form->id ) {
add_filter( 'wp_kses_allowed_html', '_formi_thankyoumsg_wp_kses_allowed_html', 99, 2 );
$message .= '<iframe src="https://fr.wikipedia.org/wiki/Main_Page" width="640" height="480">'; // replace URL with your own
}
return $message;
},
10,
3
);
function _formi_thankyoumsg_wp_kses_allowed_html( $tags, $context ) {
remove_filter( 'wp_kses_allowed_html', '_formi_thankyoumsg_wp_kses_allowed_html' );
if ( 'post' === $context ) {
$tags['iframe'] = array(
'src' => true,
'height' => true,
'width' => true,
'frameborder' => true,
'allowfullscreen' => true,
);
}
return $tags;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment