piwik/plugins/UsersManager/API.php
/**
     * Add a user in the database.
     * A user is defined by
     * - a login that has to be unique and valid
     * - a password that has to be valid
     * - an alias
     * - an email that has to be in a correct format
     *
     * @see userExists()
     * @see isValidLoginString()
     * @see isValidPasswordString()
     * @see isValidEmailString()
     *
     * @exception in case of an invalid parameter
     */
Add a user in the database.
A user is defined by
- a login that has to be unique and valid
- a password that has to be valid
- an alias
- an email that has to be in a correct format



@exception in case of an invalid parameter
Add a user in the database . A user is defined by - a login that has to be unique and valid - a password that has to be valid - an alias - an email that has to be in a correct format @exception in case of an invalid parameter
public function addUser($userLogin, $password, $email, $alias = false, $_isPasswordHashed = false)
    {
        Piwik::checkUserHasSuperUserAccess();
        $this->checkLogin($userLogin);
        $this->checkEmail($email);
        $password = Common::unsanitizeInputValue($password);
        if (!$_isPasswordHashed) {
            UsersManager::checkPassword($password);
            $passwordTransformed = UsersManager::getPasswordHash($password);
        } else {
            $passwordTransformed = $password;
        }
        $alias = $this->getCleanAlias($alias, $userLogin);
        $token_auth = $this->getTokenAuth($userLogin, $passwordTransformed);
        $this->model->addUser($userLogin, $passwordTransformed, $email, $alias, $token_auth, Date::now()->getDatetime());
        Access::getInstance()->reloadAccess();
        Cache::deleteTrackerCache();
        Piwik::postEvent('UsersManager.addUser.end', array($userLogin, $email, $password, $alias));
    }
public function addUser ( $ userLogin , $ password , $ email , $ alias = false , $ _isPasswordHashed = false ) { Piwik :: checkUserHasSuperUserAccess ( ) ; $ this -> checkLogin ( $ userLogin ) ; $ this -> checkEmail ( $ email ) ; $ password = Common :: unsanitizeInputValue ( $ password ) ; if ( ! $ _isPasswordHashed ) { UsersManager :: checkPassword ( $ password ) ; $ passwordTransformed = UsersManager :: getPasswordHash ( $ password ) ; } else { $ passwordTransformed = $ password ; } $ alias = $ this -> getCleanAlias ( $ alias , $ userLogin ) ; $ token_auth = $ this -> getTokenAuth ( $ userLogin , $ passwordTransformed ) ; $ this -> model -> addUser ( $ userLogin , $ passwordTransformed , $ email , $ alias , $ token_auth , Date :: now ( ) -> getDatetime ( ) ) ; Access :: getInstance ( ) -> reloadAccess ( ) ; Cache :: deleteTrackerCache ( ) ; Piwik :: postEvent ( 'UsersManager.addUser.end' , array ( $ userLogin , $ email , $ password , $ alias ) ) ; }
Add a user in the database.
Add a user in the database .
// we reload the access list which doesn't yet take in consideration this new user /**
         * Triggered after a new user is created.
         *
         * @param string $userLogin The new user's login handle.
         */