// If not administrator, don't show or permit access to the main dashboard
function glmRemoveDashboard () {
- global $current_user, $menu, $submenu, $config;
+ global $menu;
- // If user isn't an administrator
- if (!in_array('administrator', $current_user->roles) && $config['settings']['enable_members']) {
+ // Specify the menu item(s) to be removed
+ $restricted = array(__('Dashboard'));
- // Get rid of the main WordPress admin "Dashboard"
- reset( $menu );
- $page = key( $menu );
- while( ( __( 'Dashboard' ) != $menu[$page][0] ) && next( $menu ) ) {
- $page = key( $menu );
- }
- if( __( 'Dashboard' ) == $menu[$page][0] ) {
- unset( $menu[$page] );
- }
- reset($menu);
+ // Point the menu array pointer to the end
+ end($menu);
- // Also redirect user away from main WordPress dashboard should they get there.
- if ( preg_match( '#wp-admin/?(index.php)?$#', $_SERVER['REQUEST_URI'] ) && ( 'index.php' != $menu[$page][2] ) ) {
- wp_redirect( get_option( 'siteurl' ) . '/wp-admin/admin.php?page=glm-members-admin-menu-member');
- }
+ // Working our way back up the menu
+ while(prev($menu)){
+
+ // Break out the data for the current menu item
+ $value = explode(' ',$menu[key($menu)][0]);
+ // 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)]);
+
+ }
}
+
+ 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', 'glmRemoveDashboard');
+
+// If members are enabled
if ( isset( $config ) && isset( $config['settings'] ) && $config['settings']['enable_members'] ) {
+
+ // Add member widgets
+
add_filter(
'glm-member-db-dashboard-member-widgets',
function ( $member = null ) {