);
} );
-// If not administrator, don't show or permit access to the main dashboard
-function glmRemoveDashboard () {
- global $menu;
+// Some menu related checks
+function glmAdminMenuTests () {
+ global $menu, $current_user, $config;
- // Specify the menu item(s) to be removed
- $restricted = array(__('Dashboard'));
+ // If not administrator, don't show or permit access to the main dashboard
+ if (!in_array('administrator', $current_user->roles)) {
- // Point the menu array pointer to the end
- end($menu);
+ // Specify the menu item(s) to be removed
+ $restricted = array(__('Dashboard'));
- // Working our way back up the menu
- while(prev($menu)){
+ // Point the menu array pointer to the end
+ end($menu);
- // Break out the data for the current menu item
- $value = explode(' ',$menu[key($menu)][0]);
+ // Working our way back up the menu
+ while(prev($menu)){
- // If there is a name for this menu and it's in the restircted list
- if(in_array($value[0]!= NULL?$value[0]:'',$restricted)) {
+ // Break out the data for the current menu item
+ $value = explode(' ',$menu[key($menu)][0]);
- // Remove this menu item
- unset($menu[key($menu)]);
+ // If there is a name for this menu and it's in the restircted list
+ if(in_array($value[0]!= NULL?$value[0]:'',$restricted)) {
+ // Remove this menu item
+ unset($menu[key($menu)]);
+
+ }
+ }
+ }
+
+ // Also check if members are turned off
+ if (!$config['settings']['enable_members']) {
+
+ // Check if this is a request to the member menu
+ if (isset($_REQUEST['page']) && $_REQUEST['page'] == 'glm-members-admin-menu-member') {
+
+ // Do an immediate redirect to the members menu page
+ $sendToUrl = get_admin_url() . "admin.php?page=glm-members-admin-menu-members";
+ wp_redirect($sendToUrl);
+ exit;
}
+
}
return;
}
-// If user isn't an administrator - Remove the main dashboard
-global $current_user;
-if (!in_array('administrator', $current_user->roles)) {
- add_action('admin_menu', 'glmRemoveDashboard');
-}
-
+add_action('admin_menu', 'glmAdminMenuTests');
// If members are enabled
if ( isset( $config ) && isset( $config['settings'] ) && $config['settings']['enable_members'] ) {