Programmatically Login User and collect data at the same time
-
Hi there,
I need a bit of help – Here is what I’m trying to do:
User visits my site where they are presented with a form which allows them to submit information. As well as all the information fields the form gives them 2 login/registration options:
1. Returning Visitor: (Enter their email address and password)
2. New Visitor: (Enter email address and password + password repeat.
Option 1: When the user submits the form they should be logged-in. On successful login the information should be committed to the database.
Option 2: Same as option 1 but but it should register the user then log them in and then commit the data.
I’ve tried to gather the data then check if they are logged in, if not then create a form pointing to the login page with all the post data set in hidden fields then using java script to submit the form.
I’m having a fair bit to trouble with this method. And it seems like a bit of a round about way to getting there. If this is the right direction to go then I’ll keep pushing on and try to make it work.
But is there better way? Is there a function like wp_log_user_in($username, $password);The information I’m asking the user to submit is trivial in nature and I’m really trying to keep the steps for the user down to an absolute minimum. I don’t want to ask the user to go and register in a separate step then come back to submit.
Any help is much appreciated.
Kind Regards,
Rhys
The topic ‘Programmatically Login User and collect data at the same time’ is closed to new replies.