-1
我發現此以下代碼在stackoverflow,它使訪問信息頁面只登錄客戶,這是非常有用的。我想對此做一個改進。信息頁面只能由特定的客戶羣訪問。顯示信息頁面只登錄和特定的客戶羣
if (isset($this->request->get['information_id']) && $this->request->get['information_id'] == '{ID}')
{
//If the information_id is provided and it matches the ID you wish to protect
if (!$this->customer->isLogged()) {
//If the customer is not logged in already, redirect them to the login page
//Use $this->session->data['redirect'] to redirect them back to this page after logging in
$this->session->data['redirect'] = $this->url->link('information/information', 'information_id=' . $this->request->get['information_id']);
//Do the redirect
$this->redirect($this->url->link('account/login', '', 'SSL'));
}
}
代碼來源:Is it possible to require a login for an OpenCart Information page, and ONLY the information page?
工作得很好。感謝這兩位編碼人員。 – Asif
出錯了。重定向是好的,但向所有客戶羣顯示。幫幫我!!! – Asif
if(!$ this-> customer-> isLogged()'||'$ this-> customer-> getCustomerGroupId()!= 1){ - 更新..請找到我更新的答案。早些時候我使用'AND'而不是'OR'。 –