Restrict menu visibility by IP addresses
-
Hi all,
I’ve tried to limit the menues to only show when following conditions are met:
(is_user_logged_in() OR ($_SERVER[‘REMOTE_ADDR’]==”x.x.x.x”))That works fine, but I want to define an array in e.g. my wp-config.php where I could whitelist all the IP’s in order to make the menu visible condition less complex…
wp-config.php contains following:
$Approved_IP_List = array(“x.x.x.x”,”y.y.y.y”,”z.z.z.z”);
if (in_array($_SERVER[‘REMOTE_ADDR’], $Approved_IP_List))
$Approved_IP = True;
else
$Approved_IP = False;I’ve tried setting the “global $Approved_IP;” but it didn’t help. I keep getting this same error over and over again.
Undefined variable: Approved_IP in /path_to_wp/wp-content/plugins/menu-items-visibility-control/init.php(113) : eval()’d code on line 1If I try using the $Approved_IP in some of my webpages, it works flawlessly – it’s only creating trouble in the “Menu Item Visibility Control” plugin
Hope you can help me solve this ??
Thanks in advance
Johnny
- The topic ‘Restrict menu visibility by IP addresses’ is closed to new replies.