简体   繁体   English

wordpress:重定向首页

[英]wordpress: Redirect homepage

The homepage of my Wordpress site is set to display my latest posts. 我的Wordpress网站的主页设置为显示我的最新帖子。

I also created a landing page which includes a form for users to fill out for a free consultation. 我还创建了一个登录页面,其中包含供用户填写以进行免费咨询的表格。

How can I make it so that when first-time users go to the homepage, they will be redirected to the landing page? 我如何才能使首次使用的用户进入首页时将他们重定向到登录页面? (But clicking on my site logo should still take them back to my regular homepage showing my latest posts.) (但是,单击我的网站徽标仍应将其带回显示我最新帖子的常规主页。)

After users have filled out the "get a free consultation" form on my landing page, we would create a cookie or something so that whenever they next visit the homepage, they will just see the regular homepage with latest posts - not see the landing page any more. 用户在我的登录页面上填写“获得免费咨询”表格后,我们将创建一个cookie或其他内容,以便下次访问该首页时,他们只会看到带有最新帖子的常规首页,而不会看到登录页面。还有。

Is there a way to write a code for this? 有没有办法为此编写代码?

Thanks in advance!!! 提前致谢!!!

setcookie() is probably a good option. setcookie()可能是一个不错的选择。

if(!$_COOKIE["been_here_before"]) {
  setcookie("been_here_before", true); 
  header('Location: /consultation'); // Your free consultation page
} 

The way to achive this is a little bit more complicated. 实现这一点的方法要复杂一些。
The best practice for this is to have your form in an overlay on the homepage, the user sees the form when accessing your website but has an option to close that layer (exemple:"already fiiled the form..."). 最佳做法是将您的表单放置在主页上,用户访问您的网站时会看到该表单,但可以选择关闭该层(例如:“已填写表单...”)。 After the user submits the form or clicks "close" then set a session variable that will be used so the user won't receive the overlay again in that session. 用户提交表单或单击“关闭”后,然后设置将要使用的会话变量,这样用户就不会在该会话中再次收到叠加层。 An website that does that is this one which asks the user to register for the newsletter. 这确实是一个网站是这样一个它要求用户的通讯登记。 If the user is already register then he can click "Already registerd?" 如果用户已经注册,则可以单击“已经注册?”。 (=Sunteti deja înregistrat?) and the overlay disapears for that session. (= Sunteti dejaînregistrat?),该会话的叠加层消失。

If the form submision is mandatory for all users to get access to the website, then force them to login in the landing page. 如果强制所有用户访问该网站,则必须强制表单登录,然后强制他们登录登录页面。 Here is an example for that. 是一个例子。

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

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