Tips and Tricks HQ Support Portal › Forums › WP eMember › WP eMember General Questions › Auto-login FREE members after registration
- This topic has 5 replies, 2 voices, and was last updated 13 years, 5 months ago by amin007.
-
AuthorPosts
-
February 3, 2011 at 6:14 pm #2639bdeshazerMember
I am requiring users to register/log in before checking out with eStore and am trying to simplify the process as much as possible. My first step was to try and have FREE members automatically logged in after they register so that they can just finish the checkout process without having to manually type in their username/password that they just created.
I am creating WP users as the eMember users are registered, all three of the “WordPress User Integration Settings” options are checked underneath WP eMember->Settings.
I tried tackling the coding of this myself but could only get it partially working. My approach was to copy and adapt a lot of the code towards the top of wp_eMember1.php and put it into eMember_misc_functions.php right after the “end of autoresponder integration” line (around line #410).
The eMember login seemed to work and “stick”, but the WordPress login information didn’t appear to get set and/or stick. I made a bit more progress “forcing” the user to be set with wp_set_current_user but this didn’t seem to hold once the show_registration_form function ends. This was confirmed by adding the result of a call to is_user_logged_in() to “$output” (showed user was logged in) and then also testing this on the re-direct page (showed user wasn’t logged in).
Here is the code that I tried, what is between the lines is what I added, above and below the lines are from the original file and are for location reference:
http://proof.deshazerstudios.com/help/autologin.txt
Any ideas on how to accomplish this?
Thanks!
February 4, 2011 at 2:40 am #28690amin007ParticipantYou will need to copy the full code from the
if(isset($_POST['doLogin']))
block in “wp_eMember1.php” and add it after the autoresponder stuff. which will do both the eMember login and WP login (if the option is used).Now the catch is with the redirection. It uses a “header” redirection which won’t work in the middle of the page (where you are trying to use). So for the redirection you will need to use the HTTP META option to redirect to the checkout URL.
February 4, 2011 at 5:13 pm #28691bdeshazerMemberThanks, I’ll give it another shot and try bringing in some more of your code and trying using your global Auth object instead of creating my own instance and see if I have any better luck.
February 5, 2011 at 3:16 am #28692amin007ParticipantIf you fail then let me know and I will give you a workaround. It involves a few lines of coding in two different files but since you are a coder you should be able to take my input and sort it out.
February 6, 2011 at 4:59 pm #28693bdeshazerMemberOk, I still can’t get this working. Here is my updated code that I tried in eMember_misc_functions.php right after the “end of autoresponder integration” line (around line #410):
http://proof.deshazerstudios.com/help/autologin.txt
Here is some error output complaining about not being able to modify headers (I’m not redirecting with this code, just added a line to the $output variable to tell me whether it thinks I’m logged into WordPress or not):
http://proof.deshazerstudios.com/help/autologin-errors.txt
and a screenshot showing that my test code at this point does think I’m logged in to both emember (login panel on left shows my info) and WordPress (circled text on right):
http://proof.deshazerstudios.com/help/autologin-screenshot.jpg
Somewhere between the end of the registration code and the display of the “Registration Complete!” message the user is being logged OUT of WordPress but not out of eMember, and I can’t find where this is happening.
Your help would be greatly appreciated!
June 8, 2011 at 3:51 am #28694amin007ParticipantJust an update… you can simply do the following to enable auto member login after the registration:
Please open the “wp_eMember1.php” file and search for the following line of code:
define('WP_EMEMBER_ENABLE_AUTO_LOGIN_AFTER_REGO', false);
Once you find it change it to the following:
define('WP_EMEMBER_ENABLE_AUTO_LOGIN_AFTER_REGO', true);
-
AuthorPosts
- You must be logged in to reply to this topic.