Adding bulk amount of users to wordpress using code

In your function.php add folowing code with all users email ids in args array as one mail id in one line. Or you can split the same using commas.

function add_user(){
$args = “[email protected]
[email protected]
[email protected]
“;
$pieces=explode(“\n”, $args);
foreach($pieces as $piece) {
$username = $piece; //username
$password = $piece; //password
$email = $piece; //email
if ( !username_exists( $username )  && !email_exists( $email ) ) {
$user_id = wp_create_user( $username, $password, $email );
$user = new WP_User( $user_id );
$user->set_role( ‘subscriber’, ‘ ); //either of ‘administrator’, ‘subscriber’, ‘editor’, ‘author’, ‘contributor’
}
}
}
add_action(‘init’,’add_user’);

Reload the website.

Please not that if you have more than 500 users, first add 500 or less users at a time. Then replace the code with next part so on…