Wednesday, May 15, 2013

Bulk adding of users to a Plone site (TTW)

This is a quick way to add new users to a Plone site, very useful in a pinch but probably not very robust (so I make no guarantees). It might possibly serve as the pattern for a "user importer", assuming someone hasn't invented one already.

Everything is done through the web (TTW) using the Zope Management Interface (ZMI), so you'll need to be an administrator.

Add the following script to your Plone instance and give the script a name, I called mine 'addusers'.

out = []
acl_users = context.acl_users
for item in container.temp:
    person = item.split(',') username = person[0]
    password = person[1]
    except ValueError, msg:
        out.append("Skipped %s, reason: %s" % (username, msg))
        out.append("Success with %s" % username)
return out

Note: the use of the role 'trainee' in my example, the role MUST exist for this to work. Also for the Python purists, that "hanging" return statement is perfectly fine, TTW Python scripts run inside Zope and return the output to your browser. If it absolutely bothers you, you can leave it out.

Under the ZMI > properties' add a 'lines' field called 'temp' it should include the usernames and passwords of the newusers (no spaces after the commas)

The 'temp' lines field should look like this:
Running the 'addusers' script will now create the users with the passwords that you defined.

Update: July 1, 2013

There are a couple other tools mentioned in the comments of this post which you may also want to look at. - can send out initial passwords in bulk - generates fake content and fake users


christian said... ?

David B said...

:) thanks Christian. Will look into that addon.

keul said...

If you need to send e-mail after creation or auto-generate starting password:

Unknown said...

Or you can just use collective.loremipsum to create 500 users with data generated from :)

Unknown said...

Might also be useful:

Sign up for my upcoming Plone 5 Book & Video tutorials

plone 5 for newbies book and videos