Skip to content

Instantly share code, notes, and snippets.

@SmashBrando
Last active May 26, 2022 14:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SmashBrando/99c88bc6ed9b93969dd9 to your computer and use it in GitHub Desktop.
Save SmashBrando/99c88bc6ed9b93969dd9 to your computer and use it in GitHub Desktop.
BigCommerce Login Redirect
This is a script for BigCommerce Store Owners.
If you are trying to force user to login before viewing your store, use this handy script.
Here is what it does:
1. If the user is not logged in, the page will redirect to the login page.
2. If the user is on the login page, they stay until they login.
3. Once they are logged in, they can freely browse.
The script does not direct the user to a specific page after login.
If you need help or would like a modification, you can drop me a line here - http://brandonjkidd.com/
<!-- place this snipet in HTMLhead.html, replace yourdomain with the url of your login page -->
<script>
$(document).ready(function(){
if(
($('#LoginOrLogoutText > div > a:contains("Sign in")').length > 0) && (window.location.href.indexOf("login") === -1)
){
window.location.assign("//www.yourdomain.com/login.php");
}
});
</script>
@fengyali
Copy link

seems like doesn't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment