Last active
January 3, 2023 02:21
-
-
Save brandonjp/d206658eab5e932dfef8706e55953b61 to your computer and use it in GitHub Desktop.
Wordpress Users: Create & Delete n New Users - Code Snippets Pro
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace FyjaHmx9; | |
require_once(ABSPATH.'wp-admin/includes/user.php' ); | |
\FyjaHmx9\create_and_delete_n_new_users(); | |
function create_new_user() { | |
$username = \uniqid(); | |
$userdata = array( | |
'user_login' => 'x_user_'.$username, | |
'user_pass' => 'x_pass_'.$username, | |
); | |
$user_id = \wp_insert_user( $userdata ) ; | |
return $user_id; | |
} | |
function delete_new_user($id) { | |
\wp_delete_user($id); | |
} | |
function create_and_delete_new_user(){ | |
$user = \FyjaHmx9\create_new_user(); | |
\FyjaHmx9\delete_new_user($user); | |
} | |
function create_and_delete_n_new_users(){ | |
$rand = \mt_rand(15,45); | |
for ($i = 0; $i < $rand; $i++){ | |
\FyjaHmx9\create_and_delete_new_user(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment