From 9827975a2973a7a61285c0061c279a69f571c494 Mon Sep 17 00:00:00 2001 From: laury Date: Fri, 20 May 2016 16:51:11 -0400 Subject: [PATCH] Redirect on login but not if on front --- index.php | 34 ++++++++++++++++++---------------- setup/adminHooks.php | 2 +- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/index.php b/index.php index 4b2c6e0..20eb693 100644 --- 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 diff --git a/setup/adminHooks.php b/setup/adminHooks.php index 4083865..7fcc24a 100644 --- a/setup/adminHooks.php +++ b/setup/adminHooks.php @@ -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'; -- 2.17.1