最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

customization - Block direct access to thank you pages

programmeradmin1浏览0评论

I have parent pages which are downloadable resources. On these pages, people will fill in a form and then be redirected to a thank you page.

The thank you pages are child pages.

I would like to block direct access to those child pages and only allow access if people were redirected from the parent pages.

I found some code online but this would means that I need to edit this code for every resource I add. I would like to code to only allow access if redirected from the parent page.

How can I achieve this?

function wpse15677455_redirect() {
$ref = wp_get_referer();
if (is_page(1911) && $ref !== ";){
   wp_redirect( get_home_url() );
}
else if(is_page(1269) && $ref !== ";){
    wp_redirect( get_home_url() );
}
else if(is_page(1825) && $ref !== ";){
    wp_redirect( get_home_url() );
}
else if(is_page(1623) && $ref !== ";){
    wp_redirect( get_home_url() ); exit();

};

发布评论

评论列表(0)

  1. 暂无评论