问题
Is there a way to restrict access to a page so that only people who are logged in and in a certain group can see the page? I really need help with this. It's for a big client and I don't want to turn it down!
Here's how it would work:
Customer is given a link via email that I will manually send out. That link is to a page in the store. In order to see it they must log in with their account. And if they are apart of the right group, then Bingo, they can see the page!
I will have 3 groups total and multiple pages. Each page will be branded for the user which is easy. I just need to be able to send out a link to a page and only people in "GROUP A" who are logged in, can see it.
回答1:
If you want to restrict access to default pages in OpenCart, you have to create a pretty simple VQMod. It should add a checkup in an common controller file (header.php is the best).
First of all, there's a standard isLogged() function in system/library/customer.php, commonly used like this:
$this->customer->isLogged();
You can also easily get customer info - id, group ID etc., using standard functions:
$this->customer->getId();
$this->customer->getCustomerGroupId();
Add these checks to index() function in catalog/common/controller/header.php and redirect on fail/success:
$this->redirect($this->url->link('information/yourpage'));
Of course, to implement all this you should know, how to use VQMod.
来源:https://stackoverflow.com/questions/25196208/in-opencart-is-there-a-way-to-restrict-access-to-a-page-so-that-only-people-who