最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Batch users creation

programmeradmin0浏览0评论

I would like to share a document with about 140 users after password authentication and I want to avoid to create manually all the 140 accounts. Is it possible to create them quickly?

UPDATE: usernames to add are stored into a text file. The question is focused on the batch users creation because I will create a password-protected area where all the users will access to download the document.

I would like to share a document with about 140 users after password authentication and I want to avoid to create manually all the 140 accounts. Is it possible to create them quickly?

UPDATE: usernames to add are stored into a text file. The question is focused on the batch users creation because I will create a password-protected area where all the users will access to download the document.

Share Improve this question edited May 8, 2013 at 9:07 matteo de felice asked May 7, 2013 at 19:32 matteo de felicematteo de felice 1231 silver badge6 bronze badges 3
  • 2 What are you asking? Do you want to batch create users or share a document? If it's the latter, how do you want to share the document? – Brian Fegter Commented May 7, 2013 at 20:09
  • I think he is referring to users only - but what form those users currently exist in (DB, CSV etc) is not stated. – vancoder Commented May 7, 2013 at 21:53
  • You are right, the question was not very clear. I'll update it. – matteo de felice Commented May 8, 2013 at 9:05
Add a comment  | 

3 Answers 3

Reset to default 2

This is a small code I wrote to batch create generic users

<?php $lock = true; //true = disabled (locked)

if(!$lock) { // if not locked
    require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php' );

    $last_registered_user = $wpdb->get_row("SELECT ID FROM $wpdb->users ORDER BY ID DESC LIMIT 1");
    $new_id = $last_registered_user->ID + 1;
    $limit = false; // extra lock

    while($new_id <= $limit) {
        wp_create_user( 'user_'.$new_id, 'changeme', 'user'.$new_id.'@example' );
        $new_id++;
    }
} else { // if locked ?>
    <h5>This script is locked to prevent accidental use.</h5>
<?php
}
?>

Setup

A couple things to do:

  1. Change unlock the script by setting $lock to false.
  2. Change the path to wp-load.php.
  3. Change $limit to the number of users you want to create.

Use

This script will create $limit number of users with the username user_andTheirID and their e-mail address [email protected]. To edit the username, once the users have been created, you will have to edit the database itself.

Extra

If you want users to change their passwords from the default, changeme, try the Force Password Change plugin by Simon Blackbourn. This will require users to change their password on their first log in. Make sure you install this plugin BEFORE you run the batch create, otherwise the right values will not be created for the existing users.

You'll need a plugin to do batch import.

This one allows you to import records from a CSV file.

Importing WordPress users from a CSV file is easily possible with this free WordPress user import export plugin by WebToffee.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论