我在我的网站上有一个感谢页面,我不希望任何人都可以直接访问它,所以我使用下面的代码,它工作正常。
add_action(\'template_redirect\', function() {
// ID of the thank you page
if (!is_page(947)) { //id of page
return;
}
// coming from the form, so all is fine
if (wp_get_referer() === get_site_url().\'/contact-us/\') {
return;
}
// we are on thank you page
// visitor is not coming from form
// so redirect to home
wp_redirect(get_home_url());
exit;
});
现在,我正在做的是,我在我的单个帖子上还有一个表单,一旦用户提交表单,它就会重定向到感谢页面,但它不会继续,因为我在我的function.php
.那么,有人知道如何从一篇帖子访问感谢页面吗?