Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // path to Elgg engine's start.php
- // (usually in html/engine/start.php or public_html/engine/start.php)
- $engineStartPath = '../html/engine/start.php';
- require_once($engineStartPath);
- // the first number to append to the username (will increment peruser)
- // ie. user2
- $startUserNumber = 2;
- // the total number of users to create
- $totalUsers = 10;
- // exit after this many failed attempts (ie. attempting to register a user with an existing username)
- $failAttempts = 10;
- while (TRUE)
- {
- try
- {
- // generate basic user details
- $username = 'username' . $startUserNumber;
- $password = $username;
- $name = ucfirst($username) . ' Smith';
- $email = $username . '@example.com';
- // increment user number
- $startUserNumber++;
- // register, enable and validate this user
- $guid = register_user($username, $password, $name, $email);
- $user = get_entity($guid);
- $user->enable();
- elgg_set_user_validation_status($user->getGUID(), true, 'script');
- echo "\nAdded username: " . $username . " - name: " . $name . " - e-mail: " . $email . " - password: " . $password;
- if (--$totalUsers == 0)
- {
- break;
- }
- }
- catch (Exception $e)
- {
- echo "\nERR:\t" . $username . " " . $e->getMessage();
- if (--$failAttempts == 0)
- {
- echo 'Too many failed attempts';
- exit(1);
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement