public function register()
    {
        if ($this->getIsNewRecord() == false) {
            throw new \RuntimeException('Calling "' . __CLASS__ . '::' . __METHOD__ . '" on existing user');
        }

        $module = UsersModule::module();

        if (empty($this->password) === true) {
            $this->password = PasswordHelper::generate($module->generatedPasswordLength);
        }

        if ($module->emailConfirmationNeeded === false) {
            $this->is_active = true;
        }

        $event = new RegistrationEvent();
        $this->trigger(self::EVENT_BEFORE_REGISTER, $event);

        if ($event->isValid === false) {
            return false;
        }

        if (!$this->save()) {
            return false;
        }

        $this->trigger(self::EVENT_AFTER_REGISTER, $event);
        return $this;
    }
public function register()
    {
        if ($this->getIsNewRecord() == false) {
            throw new \RuntimeException('Calling "' . __CLASS__ . '::' . __METHOD__ . '" on existing user');
        }

        $module = UsersModule::module();

        if (empty($this->password) === true) {
            $this->password = PasswordHelper::generate($module->generatedPasswordLength);
        }

        if ($module->emailConfirmationNeeded === false) {
            $this->is_active = true;
        }

        $event = new RegistrationEvent();
        $this->trigger(self::EVENT_BEFORE_REGISTER, $event);

        if ($event->isValid === false) {
            return false;
        }

        if (!$this->save()) {
            return false;
        }

        $this->trigger(self::EVENT_AFTER_REGISTER, $event);
        return $this;
    }
public function register ( ) { if ( $ this -> getIsNewRecord ( ) == false ) { throw new \ RuntimeException ( 'Calling "' . __CLASS__ . '::' . __METHOD__ . '" on existing user' ) ; } $ module = UsersModule :: module ( ) ; if ( empty ( $ this -> password ) === true ) { $ this -> password = PasswordHelper :: generate ( $ module -> generatedPasswordLength ) ; } if ( $ module -> emailConfirmationNeeded === false ) { $ this -> is_active = true ; } $ event = new RegistrationEvent ( ) ; $ this -> trigger ( self :: EVENT_BEFORE_REGISTER , $ event ) ; if ( $ event -> isValid === false ) { return false ; } if ( ! $ this -> save ( ) ) { return false ; } $ this -> trigger ( self :: EVENT_AFTER_REGISTER , $ event ) ; return $ this ; }
This method is used to register new user account.

@return bool|User
This method is used to register new user account .