Right now I have a multi-store set up and am making a change to have each store as its own website instead of just one website with multiple stores so that i can take advantage of different payment methods and shipping methods per website. This is a single installation.
What I'm interested in is having a primary public website that anyone can visit, and each of the other websites only allow specific users. I'm currently looking at requiring the customer to have a custom attribute set by an administrator. Is it possible to only allow a customer into a store front end if they have either a customer attribute, or customer group set appropriately? If not, is there another way of doing it?
Solved! Go to Solution.
Firstly , good question and concept you are thinking.
Yes it is possible , AKAIK we can do this by force login meaning from other stores/site which you wanted to make it private and not able to see all the users for that you need to redirect to directly login screen.
Means when user hits the URL of the private site in the browser you just need to redirect to login screen of the website , where you need to make registration link disable so no registration allowed over there , only those user can logged in which you have assigned user group from the magento backend.
Example - if you have create TEST user group and assign this to XYZ from backend , then only that XYZ user can logged in into that site.
Thanks for the reply - a few followup questions to make sure I understand what you mean.
Lets say of I have a single installation with 3 websites, and each website has a single store. These stores will have different base url's and are set up in NginX.
Website A is open to the public and does not require registration.
Website B is private, only accessible to users with user group "Website B"
Website C is private, only accessible to users with user group "Website C"
I would like to share users between all of these sites, all I want to do is make it so that if a user goes to Website B, and only has group 'Website C', they get redirected to website A, which is public. So there are really two points:
1.) Inside of Magento, can I check all requests to see what site they're going to?
2.) When I see the url, can I pull in the customer data and make sure they have the right group?
Obviously if the user isn't registered, they'd just be redirected the same as if they didn't have that group.
Looks like you understand correctly.
Coming back to detail answer :
RE : 1.) Inside of Magento, can I check all requests to see what site they're going to?
- Yes definitely , you can always get websiteID and storeId in all the request if you wanted to get.
RE : 2.) When I see the url, can I pull in the customer data and make sure they have the right group?
- Yes - definitely you can get custom Group with customer data on each and every request.
magento 2 have like Event observer and Plugin concept , so you can use based on your requirement and do it for the same.
Hope it helps