【发布时间】:2021-12-13 22:13:04
【问题描述】:
我有一个用户填写的联系表 (cf7),我希望在提交表单时显示一个弹出窗口(我已经把这部分记下来了),并显示可变的内容主体,具体取决于在下拉框中用户选择的项目上。我目前正在使用 wppopupmaker,但我无法弄清楚如何用我所拥有的东西来达到这个目的。
感谢您的帮助!
【问题讨论】:
标签: wordpress popup contact-form-7
我有一个用户填写的联系表 (cf7),我希望在提交表单时显示一个弹出窗口(我已经把这部分记下来了),并显示可变的内容主体,具体取决于在下拉框中用户选择的项目上。我目前正在使用 wppopupmaker,但我无法弄清楚如何用我所拥有的东西来达到这个目的。
感谢您的帮助!
【问题讨论】:
标签: wordpress popup contact-form-7
创建一个引导模式弹出窗口,然后在 function.php 中添加这个函数
<?php add_action( 'wp_footer', 'mycustom_wp_footer' );
function mycustom_wp_footer() {
?>
<script type="text/javascript">
document.addEventListener( 'wpcf7mailsent', function( event ) {
if ( '34' == event.detail.contactFormId ) { // Change 123 to the ID of the form
jQuery('#myModal2').modal('show'); //this is the bootstrap modal popup id
}
}, false );
</script>
<?php } ?>
或
add_action('wpcf7_mail_sent', function ($cf7) {
// Run code after the email has been sent
$wpcf = WPCF7_ContactForm::get_current();
$wpccfid=$wpcf->id;
// if you wanna check the ID of the Form $wpcf->id
if ( '34' == $wpccfid ) { // Change 123 to the ID of the form
echo '
<div class="modal fade in formids" id="myModal2" role="dialog" style="display:block;" tabindex="-1">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content no_pad text-center">
<button type="button" class="close" data-dismiss="modal">×</button>
<div class="modal-header heading">
<h3 class="modal-title">Message Sent!</b></h3>
</div>
<div class="modal-body">
<div class="thanku_outer define_float text-center">
<h3>Thank you for getting in touch!</h3>
</div>
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>
';
}
});
【讨论】: