Simple Membership Plugin › Forums › Simple Membership Plugin › Password change causes 'is_user_logged_in' to return 'false'
- This topic has 1 reply, 1 voice, and was last updated 11 years, 3 months ago by
lewsj.
-
AuthorPosts
-
January 6, 2015 at 5:02 pm #786
lewsj
ParticipantHi there,
I am currently experiencing a major issue with the Simple Membership plugin. The site I am working on is currently set up to show a “Welcome, User” message in a bespoke header bar when a registered user is logged in, and a “Members Login” button when the user is not logged in. To do this, I am using a conditional PHP statement that calls WordPress’
is_user_logged_in()function.When a new user is created, this code works perfectly – if the user is logged in, the welcome message appears along with a dropdown menu (with the option to view their profile and logout), and if they are logged out then a link to the login page replaces it.
The problem arises when the password is either reset using the plugin’s password reset page, or changes using the plugin’s profile page. Calling the function
is_user_logged_in()will always returnfalseif the password has been changed in the front-end (if the password is changed through WordPress’ backend, this issue does not occur), and therefore the “Members Login” button is always shown in place of the user’s welcome message.Here is the relevant header code I am using, including steps needed to recreate the problem:
<div class="headerBar"> <?php function checkUser() { global $current_user; get_currentuserinfo(); $userID = $current_user->ID; if ( is_user_logged_in() ) { ?> <div class="userPIWInfo"> <?php global $current_user; echo 'Welcome, ' . $current_user->user_firstname . "\n"; ?> <div class="userDropdown"> <a href="<?php home_url(); ?>/clients/piw/membership-login/membership-profile/">My Profile</a> <a href="<?php echo wp_logout_url( home_url() ); ?>" title="Logout">Logout</a> </div> </div> <?php } else { ?> <a id="memberLogin" href="<?php home_url(); ?>/clients/piw/membership-login/">Members Login</a> <?php } } checkUser(); ?> </div>- Create a new user.
- Login as user.
- See that the “Member Login” button disappears and is replaced by “Welcome,
User's First Name“. WordPress admin bar also appears (“Hide Adminbar” is unchecked in plugin settings). - Logout.
- Click “Forgot Password”.
- Enter email and reset password.
- Login as user with new password.
- “Member Login” button persists (as
is_user_logged_in()has now returned false). Admin bar is not shown.
It seems that for some reason when the plugin is changing the user’s password that this information is somehow not being relayed to the WordPress backend? Any help in this matter is greatly appreciated.
January 7, 2015 at 10:09 am #796lewsj
ParticipantIn case anyone else is having this issue, I managed to look through the plugin files and find out how the user is being authenticated. I have added the updates to the first part of the code below, in case anyone else has the same issue.
<?php function checkUser() { $auth = BAuth::get_instance(); if ( $auth->is_logged_in() ) { ?> <div class="userPIWInfo"> <?php echo 'Welcome, ' . $auth->userData->first_name . "\n"; ?> -
AuthorPosts
- You must be logged in to reply to this topic.