Update for redirect on login.
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 27 Oct 2016 15:26:18 +0000 (11:26 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 27 Oct 2016 15:26:18 +0000 (11:26 -0400)
When logging in as subscriber goto the conditions page not profile edit
page.

index.php
setup/adminHooks.php

index 77d5ff7..a88ec80 100644 (file)
--- 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 <cscott@gaslightmedia.com>
  * @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.
index 2ab608a..d658c3b 100644 (file)
  *
  *  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');