Redirect on login but not if on front
authorlaury <laury@gaslightmedia.com>
Fri, 20 May 2016 20:51:11 +0000 (16:51 -0400)
committerlaury <laury@gaslightmedia.com>
Fri, 20 May 2016 20:51:11 +0000 (16:51 -0400)
index.php
setup/adminHooks.php

index 4b2c6e0..20eb693 100644 (file)
--- a/index.php
+++ b/index.php
@@ -229,26 +229,28 @@ if ($wpUserID) {
  * Add filter to redirect user to a particular destination on
  * login based on their roles.
  */
-/*
-function my_login_redirect( $redirect_to, $request, $user ) {
-
-    global $user;
 
-    // Do we have a logged in user
-    if ( isset( $user->roles ) && is_array( $user->roles ) ) {
-
-        // If this is a non-contact user or one with a pre-existing non-contact login
-        foreach ($user->roles as $r) {
-            if (substr($r,0,12) != 'glm_members_') {
-                // Go to normal destination for this user
-                return $redirect_to;
+function my_login_redirect( $redirect_to, $request, $user ) {
+    if (get_option('glm_member_db_frontend_login_request') == false) {
+        update_option('glm_member_db_frontend_login_request', true);
+        global $user;
+
+        // Do we have a logged in user
+        if ( isset( $user->roles ) && is_array( $user->roles ) ) {
+
+            // If this is a non-contact user or one with a pre-existing non-contact login
+            foreach ($user->roles as $r) {
+                if (substr($r,0,12) != 'glm_members_') {
+                    // Go to normal destination for this user
+                    return $redirect_to;
+                }
             }
-        }
 
-        // If we get here, this is a pure contact user, start them at their profile
+            // If we get here, this is a pure contact user, start them at their profile
 
-        return '/wp-admin/admin.php?page=glm-members-admin-menu-member';
+            return '/wp-admin/admin.php?page=glm-members-admin-menu-member';
 
+        }
     }
 
     // No logged in user - So why is the "login_redirect" filter triggered anyway?
@@ -256,6 +258,6 @@ function my_login_redirect( $redirect_to, $request, $user ) {
 
 }
 add_filter( 'login_redirect', 'my_login_redirect', 10, 3 );
-*/
+
 
 ?>
\ No newline at end of file
index 4083865..7fcc24a 100644 (file)
@@ -28,7 +28,7 @@
 
 
 // Add content to member detail page
-add_filter('glm-member-db-admin-management-hoooksHelp', function($content) {
+add_filter('glm-member-db-admin-management-hooksHelp', function($content) {
 
         // Read in this plugin/addon hook help file
         $fname = GLM_MEMBERS_CONTACTS_PLUGIN_PATH.'/setup/hooksHelp.html';