$user = eZUser::currentUser(); $user->setAttribute('login_count', $user->attribute('login_count') + 1); $user->store(); eZUser::setCurrentlyLoggedInUser($user);
$user = eZUser::fetchByEmail('test@example.com'); if (!$user) { $user = eZUser::create(array('email' => 'test@example.com')); $user->store(); } eZUser::setCurrentlyLoggedInUser($user);This example fetches a user by email, and if not found, creates a new user with the email address and then sets it as the currently logged in user. This method is part of the eZ Publish package library.