I take it users can be created on the fly by using user_save but by not passing a uid in the $account object.

This seems to create the user but doesn't log them in.

I am trying to add this to the first part of a multistep form, so that on the first page they enter their email, password and some of the profile fields which is some basic information I need to get before the user can go any further, but this doesn't work.

I have also tried using profile_save_profile and setting $register to TRUE but this doesn't even create the user let alone log them in.

When I use user_save the user is created and I set $user by using $user = user_save(...).

The $user object has everything in it, but it obviously isn't creating the users session.

I have tried sess_regenerate() with no success.

The only other option is to redirect non logged in users to a login page with the option to register, but if I do this I want to redirect the user back to the registration form but this had never worked for me.

Comments

jamestombs’s picture

No-one?

James T
Action Medical Research - www.action.org.uk

James T
Action Medical Research - www.action.org.uk

regenwethernolanj’s picture

I did see in a book that you can run a call like this that will check to see if a user is logged in, and if not itll log them in and if they dont exist it will create them. it was like this ...
user_external_login_register($username, $password);
Hope that helps...

jamestombs’s picture

Although it is a d6 function, the api code looks useful, thanks.

James T
Action Medical Research - www.action.org.uk

James T
Action Medical Research - www.action.org.uk