From: Steve Sutton Date: Thu, 27 Oct 2016 15:26:18 +0000 (-0400) Subject: Update for redirect on login. X-Git-Tag: v1.0.2^2 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=0e4755a1e31da7d82450eb6699aa35378f6a338f;p=WP-Plugins%2Fglm-member-db-conditions.git Update for redirect on login. When logging in as subscriber goto the conditions page not profile edit page. --- diff --git a/index.php b/index.php index 77d5ff7..a88ec80 100644 --- a/index.php +++ b/index.php @@ -3,7 +3,7 @@ * Plugin Name: GLM Members Database Conditions * Plugin URI: http://www.gaslightmedia.com/ * Description: Gaslight Media Members Database. - * Version: 1.0.1 + * Version: 1.0.2 * Author: Gaslight Media * Author URI: http://www.gaslightmedia.com/ * License: GPL2 @@ -19,7 +19,7 @@ * @package glmMembersDatabaseConditionsAddOn * @author Chuck Scott * @license http://www.gaslightmedia.com Gaslightmedia - * @version 1.0.1 + * @version 1.0.2 */ /* @@ -37,7 +37,7 @@ * so that we're sure the other add-ons see an up to date * version from this plugin. */ -define('GLM_MEMBERS_CONDITIONS_PLUGIN_VERSION', '1.0.1'); +define('GLM_MEMBERS_CONDITIONS_PLUGIN_VERSION', '1.0.2'); define('GLM_MEMBERS_CONDITIONS_PLUGIN_DB_VERSION', '0.0.2'); // This is the minimum version of the GLM Members DB plugin require for this plugin. diff --git a/setup/adminHooks.php b/setup/adminHooks.php index 2ab608a..d658c3b 100644 --- a/setup/adminHooks.php +++ b/setup/adminHooks.php @@ -37,3 +37,31 @@ * * Also note that parameters will be in the context of the main admin controller constructor. */ +function glmConditionsRemoveDashboard () { + global $current_user, $menu, $submenu, $config; + + // If user isn't an administrator + if (in_array('subscriber', $current_user->roles) && !$config['settings']['enable_members']) { + + // 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-conditions-conditions'); + } + if ( preg_match( '#wp-admin/?(profile.php)?$#', $_SERVER['REQUEST_URI'] ) && ( 'profile.php' != $menu[$page][2] ) ) { + wp_redirect( get_option( 'siteurl' ) . '/wp-admin/admin.php?page=glm-members-admin-menu-conditions-conditions'); + } + + } +} +add_action('admin_menu', 'glmConditionsRemoveDashboard');