Want to display a menu item for specific customer group?

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:
Code:
------------------------
'settings' => array(
                'name'      => Yii::t('app', 'Settings'),
                'icon'      => 'glyphicon-cog',
                'active'    => 'settings',
                'route'     => null,
                'items'     => array(),
            ),
------------------------
And below code under above (I added a menu called "Squeeze Page Tool")
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
            ),
------------------------
2. Find below content:
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
        }
------------------------
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:

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.');
}
------------------------
Hope this help.
 
Last edited:
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:
Code:
------------------------
'settings' => array(
                'name'      => Yii::t('app', 'Settings'),
                'icon'      => 'glyphicon-cog',
                'active'    => 'settings',
                'route'     => null,
                'items'     => array(),
            ),
------------------------
And below code under above (I added a menu called "Squeeze Page Tool")
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
            ),
------------------------
2. Find below content:
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
        }
------------------------
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:

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.');
}
------------------------
Hope this help.

Could this be useful?
https://forum.mailwizz.com/threads/how-to-add-a-custom-payment-page-options.70
(it does discuss new menu items)
 
Last edited:
Back
Top