/** * @param $username * * @return int|bool */ public function addUserToSMF($username) { if (empty($username)) { $this->modx->log(modX::LOG_LEVEL_ERROR, "[SMF] Could not add new user to SMF: empty username"); $this->logCallTrace(); return null; } $password = !empty($_REQUEST['specifiedpassword']) && !empty($_REQUEST['confirmpassword']) && $_REQUEST['specifiedpassword'] == $_REQUEST['confirmpassword'] ? $_REQUEST['specifiedpassword'] : ''; /** @var modUser $user */ if ($user = $this->modx->getObject('modUser', array('username' => $username))) { /** @var modUserProfile $profile */ $profile = $user->getOne('Profile'); $create = array('member_name' => $user->username, 'email' => $profile->email, 'password' => !empty($password) ? $password : sha1(rand() + time()), 'require' => $user->active && !$profile->blocked ? 'nothing' : '', 'real_name' => !empty($profile->fullname) ? $profile->fullname : $user->username, 'date_registered' => !empty($user->createdon) ? $user->createdon : time(), 'birthdate' => !empty($profile->dob) ? $profile->dob : '0000-00-00', 'website_url' => $profile->website, 'location' => $profile->city); $response = smfapi_registerMember($create); if (is_int($response)) { return $response; } elseif (is_array($response)) { $this->modx->log(modX::LOG_LEVEL_ERROR, "[SMF] Could not add new user \"{$username}\" {$this->modx->event->name} to SMF: " . print_r($response, true)); } } return false; }
/** * Short description * * Long description * * @param * @return */ protected function register_member() { try { $this->loadApi(); } catch (Exception $e) { throw new \Exception($e->getMessage()); } $this->regOptions = unserialize($this->regOptions); $this->data = smfapi_registerMember($this->regOptions); }