Bigcommerce-如果未登录,如何将用户从首页重定向到登录页面 [英] Bigcommerce - How to redirect users to login page from homepage if not logged in

查看:185
本文介绍了Bigcommerce-如果未登录,如何将用户从首页重定向到登录页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果客户未登录,我如何让他们看到登录页面而不是首页?我尝试使用以下代码,但是即使客户已登录,它也会重定向到登录页面.

How do I have customers see the login page instead of the homepage if they are not logged in? I tried using the following code but it redirects to the login page even if the customer is logged in.

<script language="javascript" type="text/javascript">//<![CDATA[
if (window.location.href.toString() == "http://www.mywebsite.com/")
{
    window.location.assign("http://www.mywebsite.com/login.php");
}
//]]></script>

推荐答案

您可以通过查看来自%%GLOBAL_LoginOrLogoutText%%代码的欢迎消息来检测用户是否已登录.

You can detect whether or not the user is logged in by looking at the welcome message that comes from the %%GLOBAL_LoginOrLogoutText%% code.

因此,如果未显示欢迎文本,请将其重定向到login.php页面.

So if that welcome text is not displayed redirect them to the login.php page.

还请注意,需要警告的是,如果它们已经在该页面上,则无需再次(一次又一次地)重定向它们.

Also note that you need a caveat that if they are already at that page you don't need to redirect them again (and again and again).

这篇关于Bigcommerce-如果未登录,如何将用户从首页重定向到登录页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆