简体   繁体   English

表单提交后在wordpress中退出()

[英]Exit() in wordpress after form submit

I have a form in wordpress, and all the values filled in the form are used to send an email to an administrator. 我在wordpress中有一个表格,表格中填写的所有值都用于向管理员发送电子邮件。

All this works well. 所有这些都很好。 I receive the email, but after running the script to send the email, I need to redirect the user to another location obviously. 我收到了电子邮件,但是运行脚本发送电子邮件后,我显然需要将用户重定向到另一个位置。

After running the mail script I use this to redirect the user: 运行邮件脚本后,我使用它来重定向用户:

header("location: " . home_url() . "");
exit();

But it seems the exit() is causing me trouble. 但是似乎exit()引起了我麻烦。 Like it trigger not to load the rest of the page. 像这样触发不加载页面的其余部分。

Any help is greatly appreciated! 任何帮助, 不胜感激!

You should use the wordpress method for redirects. 您应该使用wordpress方法进行重定向。 wp_redirect is your answer wp_redirect是您的答案

wp_redirect(home_url());
exit;

documentation for wp_redirect() can be found here: wordpress reference wp_redirect()文档可以在这里找到: wordpress参考

Use wp redirect 使用wp重定向

<?php
wp_redirect( $location, $status );
exit;
?>

more about 更多关于

https://codex.wordpress.org/Function_Reference/wp_redirect https://codex.wordpress.org/Function_Reference/wp_redirect

您可以使用它。

wp_redirect(get_permalink(ID));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM