namph81
New Member
Below is my example, I have 3 customer groups:
- FREE
- PRO
- ADVANCED
Now I want to display a menu item (a link to one of my tool) for PRO and ADVANCED groups.
And FREE group cannot access to the tool even they know the URL.
Target file: LeftSideNavigationWidget.php
1. Find below content:
And below code under above (I added a menu called "Squeeze Page Tool")
2. Find below content:
And below code under above (write cookie with value NO for FREE group that has ID=1, other group is YES)
3. Check cookie in the tool
If the cookie is not set or set to NO, display warning message.
I added below code to the beginning of the index.php file of the tool:
Hope this help.
- FREE
- PRO
- ADVANCED
Now I want to display a menu item (a link to one of my tool) for PRO and ADVANCED groups.
And FREE group cannot access to the tool even they know the URL.
Target file: LeftSideNavigationWidget.php
1. Find below content:
Code:
------------------------
'settings' => array(
'name' => Yii::t('app', 'Settings'),
'icon' => 'glyphicon-cog',
'active' => 'settings',
'route' => null,
'items' => array(),
),
------------------------
Code:
------------------------
'squeezepage' => array(
'name' => Yii::t('app', 'Squeeze Page Tool'), //Name of the menu
'icon' => 'glyphicon-sound-stereo', //Icon
'active' => null,
'route' => 'http://yourdomain.com/tools/squeezepage/', //URL of the tool
'linkOptions' => array('target' => '_blank'), //Open in new tab
),
------------------------
Code:
------------------------
if (!Yii::app()->options->get('system.customer.action_logging_enabled', true)) {
unset($menuItems['dashboard']);
}
------------------------
And below code under above (write cookie with value NO for FREE group that has ID=1, other group is YES)
Code:
------------------------
$cookie_name = "MSD_SQUEEZEPAGE_ALLOW";
$cookie_value = "YES";
setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/"); // 86400 = 1 day
if ($customer->group_id == 1) { //Check if FREE group
unset($menuItems['squeezepage']); //Hide the menu to FREE group
$cookie_value = "NO";
setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/"); // 86400 = 1 day
}
------------------------
If the cookie is not set or set to NO, display warning message.
I added below code to the beginning of the index.php file of the tool:
Code:
------------------------
$cookie_name = "MSD_SQUEEZEPAGE_ALLOW";
if(!isset($_COOKIE[$cookie_name])) {
exit('We are sorry but this tool is not available for FREE Group.');
} else {
if ($_COOKIE[$cookie_name] == "NO")
exit('We are sorry but this tool is not available for FREE Group. Please upgrade to PRO or ADVANCED plan.');
}
------------------------
Last edited: