views:

140

answers:

2

I have Ubercart installed. I'd like to create a Conditional Action after an anonymous user finishes checking out. The system currently creates a user automatically, but it does not log them in - I want this conditional action to log them in.

The conditional action allows me to write custom PHP to perform whatever I want - and what I want to do is log in the user. How can I do this?

+1  A: 

It depends what variables you got. In Drupal, the global $user is the user object of the logged in user so you can do something like this:

global $user; // if user isn't logged in, $user is the anonymous user.
$user = user_load($uid); // $user is now the user you loaded.

You have to take care when doing stuff like this, so you don't accidentally log in users with the wrong user, like a user with admin privileges. In the above example, $uid is the id of the user you want to get.

googletorp
+4  A: 

No need to write your own conditional action. Visit your site at:

http://yoursite.com/admin/store/settings/checkout/edit/basic

there's a checkbox towards the bottom of the page that if enabled will allow you to automatically check-in users that are created automatically by the system at checkout.

HTH!

mac