From: Steve Sutton Date: Fri, 9 Sep 2016 19:18:00 +0000 (-0400) Subject: Merge branch 'develop' into feature/memberDashboard X-Git-Tag: v2.7.0^2~1^2~16 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=5e8d7fafe434b6dcae5484ae9f3afd8096d7f2d3;p=WP-Plugins%2Fglm-member-db.git Merge branch 'develop' into feature/memberDashboard --- 5e8d7fafe434b6dcae5484ae9f3afd8096d7f2d3 diff --cc setup/adminHooks.php index 2caea112,0076fe75..d10ba2cc --- a/setup/adminHooks.php +++ b/setup/adminHooks.php @@@ -121,12 -121,34 +121,40 @@@ add_action( 'add_meta_boxes', function( // )); // } //} + - + // If not administrator, don't show or permit access to the main dashboard + function glmRemoveDashboard () { + global $current_user, $menu, $submenu; + + // If user isn't an administrator + if (!in_array('administrator', $current_user->roles)) { + + // 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); + + // 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'); + } + + } + } + add_action('admin_menu', 'glmRemoveDashboard'); + - -?> +add_filter( + 'glm-member-db-dashboard-member-widgets', + function ( $member = null ) { + $content .= $this->controller( 'dashboard', 'index', $member ); + return $content; + }, + 10, + 1 +);