A space to discuss online store customization, theme development, and Liquid templating.
Hi all,
I am trying to limit this page to only my logged-in users, non logged-in users should be prompted to sign up for an account.
Is there way to do so?
Link: https://trytrysg.myshopify.com/pages/share-review
Solved! Go to the solution
This is an accepted solution.
You can also avoid using a third-party app and just write a few lines of code to either hide the section or redirect the user.
This is an accepted solution.
Here's a test of it: redirect when not logged in – practice-agood
password: 1
Here's the script
{% if customer == nil %}
<h1>Redirecting, See you!</h1>
<script>
addEventListener("load", (event) => {
let redirect_path = "https://www.google.com";
window.location.replace(redirect_path);
});
</script>
{% endif %}
Hmmm. Shopify has a way to add redirects, but it looks like it redirects everyone. Shopify Help Center | URL redirects
Normally this should be done in the backend, but you can write a script that will redirect the user if they are not logged in with Liquid and JS.
This is an accepted solution.
Here's a test of it: redirect when not logged in – practice-agood
password: 1
Here's the script
{% if customer == nil %}
<h1>Redirecting, See you!</h1>
<script>
addEventListener("load", (event) => {
let redirect_path = "https://www.google.com";
window.location.replace(redirect_path);
});
</script>
{% endif %}
Hi, thanks for the reply. I will message you.
Cool. Just do so and I'll reply when I'm available.
Sorry, can't seem to find a way to message you directly. Can I know where can I add your code to my page?
Click on my profile and you should see send a message button. Unfortunately, I need to look at your theme first before deciding where to add the code.
Doesn't seem to have the option, can I get your email? Or could you email me at asktrytry@gmail.com please? Thank you!
Sent you an email. You can now remove your email in your message by editing it.
Hi @AskTryTry,
You can use a third-party app to hide the section from all visitors excluding the logged-in users. This will solve your issue with ease and prevent any frustrations or issues in the future.
Locksmith has been one of the most used apps for this. Give it a shot. Alternatively, you can look for other apps here.
Have a nice one!
This is an accepted solution.
You can also avoid using a third-party app and just write a few lines of code to either hide the section or redirect the user.