How To Restrict Page To Be Accessed By Vendors Only

Hi Guys,

I'm using the latest version of Multi-Vendor Platform. Can you please help me out on how can I configure to restrict a page to be accessed by Vendors only? If the Vendor is not currently logon it will redirect the Vendor to login first before having able to access a restricted page.

The reason I want to have this restriction is to keep the exclusive information for Vendors only which a normal customer doesn't need to have access or to know.

You can create pages.post.php controller in the My changes module and check user type in it

Hi eComLabs,

Thanks for your reply. Would you be kind to let me know how I will do that?

A guide would be much appreciated.

- enable My changes addon
- create app/addons/my_changes/controllers/frontend/pages.post.php

use Tygh\Registry;

if (!defined(‘BOOTSTRAP’)) { die(‘Access denied’); }

if ($_SERVER[‘REQUEST_METHOD’] == ‘POST’) {
return;
}

if ($mode == ‘view’) {
$page_data = Tygh::$app[‘view’]->getTemplateVars(‘page’);
if (!empty($page_data) && empty($auth[‘user_id’]) && $auth[‘user_type’] == ‘V’) {
$vendor_page_ids = array(
11,
23
);
if (in_array($page_data[‘page_id’], $vendor_page_ids)) {
return array(
CONTROLLER_STATUS_REDIRECT,
‘auth.login_form?return_url=’ . urlencode(Registry::get(‘config.current_url’))
);
}
}
}

- replace IDs of pages (can be checked in backend)

- check the result

(!) Not tested

Thanks eComLab, will test and check it.

Appreciate your help.