public function createAccount($userNames)
    {
        if (!is_array($userNames)) {
            $userNames = array($userNames);
        }

        foreach ($userNames as $userName) {
            if (empty($userName)) {
                continue;
            }

            if (!in_array($userName, $this->getLocalAccounts())) {

                //Do a sanity check
                if ($this->userNameExists($userName) === false) {

                    try {
                        $userId = wp_insert_user(
                            array(
                                'user_login' => $userName,
                                'user_pass' => wp_generate_password(),
                                'user_nicename' => $userName,
                                'user_email' => $this->createFakeEmail($userName),
                                'user_registered' => date('Y-m-d H:i:s'),
                                'role' =>  $this->defaultRole
                            )
                        );
                    } catch (\Exception $e) {
                        error_log("Error: Could not create a new user using bulk data (ad-api-integration).");
                    }

                } else {
                    $userId = null;
                }

                if (is_numeric($userId)) {
                    $this->setUserRole($userId);
                }
            }
        }
    }
public function createAccount($userNames)
    {
        if (!is_array($userNames)) {
            $userNames = array($userNames);
        }

        foreach ($userNames as $userName) {
            if (empty($userName)) {
                continue;
            }

            if (!in_array($userName, $this->getLocalAccounts())) {

                //Do a sanity check
                if ($this->userNameExists($userName) === false) {

                    try {
                        $userId = wp_insert_user(
                            array(
                                'user_login' => $userName,
                                'user_pass' => wp_generate_password(),
                                'user_nicename' => $userName,
                                'user_email' => $this->createFakeEmail($userName),
                                'user_registered' => date('Y-m-d H:i:s'),
                                'role' =>  $this->defaultRole
                            )
                        );
                    } catch (\Exception $e) {
                        error_log("Error: Could not create a new user using bulk data (ad-api-integration).");
                    }

                } else {
                    $userId = null;
                }

                if (is_numeric($userId)) {
                    $this->setUserRole($userId);
                }
            }
        }
    }
public function createAccount ( $ userNames ) { if ( ! is_array ( $ userNames ) ) { $ userNames = array ( $ userNames ) ; } foreach ( $ userNames as $ userName ) { if ( empty ( $ userName ) ) { continue ; } if ( ! in_array ( $ userName , $ this -> getLocalAccounts ( ) ) ) { //Do a sanity check if ( $ this -> userNameExists ( $ userName ) === false ) { try { $ userId = wp_insert_user ( array ( 'user_login' => $ userName , 'user_pass' => wp_generate_password ( ) , 'user_nicename' => $ userName , 'user_email' => $ this -> createFakeEmail ( $ userName ) , 'user_registered' => date ( 'Y-m-d H:i:s' ) , 'role' => $ this -> defaultRole ) ) ; } catch ( \ Exception $ e ) { error_log ( "Error: Could not create a new user using bulk data (ad-api-integration)." ) ; } } else { $ userId = null ; } if ( is_numeric ( $ userId ) ) { $ this -> setUserRole ( $ userId ) ; } } } }
Creates a single user if it not exists.
@param string $userName A string with a username that corresponds to the ad username.
@param string $userEmail A string with a email adress that corresponds to the ad email adress.
@trow \Exception
@return void
Creates a single user if it not exists .