/** * Creates a user in the system * * Example: * <code> * <?php * $model = FD::model( 'Users' ); * $model->create( $username , $email , $password ); * * ?> * </code> * * @since 1.0 * @access public * @param SocialTableRegistration The registration object. * @return int The last sequence for the profile type. * * @author Mark Lee <*****@*****.**> */ public function create($data, SocialUser $user, SocialTableProfile $profile) { // Get a list of user groups this profile is assigned to $json = FD::json(); $groups = $json->decode($profile->gid); // Need to bind the groups under the `gid` column from Joomla. $data['gid'] = $groups; // Bind the posted data $user->bind($data, SOCIAL_POSTED_DATA); // Detect the profile type's registration type. $type = $profile->getRegistrationType(); // We need to generate an activation code for the user. if ($type == 'verify') { $user->activation = FD::getHash(JUserHelper::genRandomPassword()); } // If the registration type requires approval or requires verification, the user account need to be blocked first. if ($type == 'approvals' || $type == 'verify') { $user->block = 1; } // Get registration type and set the user's state accordingly. $user->set('state', constant('SOCIAL_REGISTER_' . strtoupper($type))); // Save the user object $state = $user->save(); // If there's a problem saving the user object, set error message. if (!$state) { $this->setError($user->getError()); return false; } // Set the user with proper `profile_id` $user->profile_id = $profile->id; // Once the user is saved successfully, add them into the profile mapping. $profile->addUser($user->id); return $user; }