Question

I've created a page using the CMS which I do not want to be accessible by people who are not logged in. It's a download page which I want to place in the footer. But when they click on it, it should either redirect them to the log in page or continue to the download page if they are already logged in.

I can't seem to find a solution for this other than buying a plugin, which I do not want.

Was it helpful?

Solution

You will want to look into creating a custom block with Dependency Injection. This will contain some basic logic such as checking if the page id is equal to ..X , and then simply redirecting them to login page (or a page of your choice).

Alternatively there is a 3rd-party Magento 2 module available which should help you achieve what you want:

https://www.mageants.com/force-login-extension-for-magento-2.html

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top