Add a batch of users (import users to Plone)

Hi everybody:

This is my insatlled Plone:

  • Plone 5.1rc2 (5109)
  • CMF 2.2.12
  • Zope 2.13.26
  • Python 2.7.13 (default, Jul 26 2017, 16:31:12) [GCC 4.3.0]
  • PIL 1.1.7

I'd like to create lots of users to the system (maybe importing a CSV file or using API). If there's an add-on or we should do it via SSH?
Also, it would be better to assign the users right to the file, so once we create (or import) the users it would in their right place.
I have read something that I can users (like a loop) that in SSH, does anybody know about that how it works?

Thank you!

I'm not sure if it works in Plone 5, but take a look at

1 Like

I'd avoid the Python script in the ZMI. It's a very old way to work.
You can use an add-on or if you are of the 'I prefer to do it myself' persuasion, you can write an external python script

Start a test installation with a copy of your real site in debug mode (bin/instance). Of if you have setup your test site with Ansible use bin/client_reserved; then experiment with the plone api:

plone_daemon@ploneprod2:/usr/local/plone-5.1-latest/ploneprod$ bin/client_reserved debug
Starting debugger (the name "app" is bound to the top-level Zope object)

>>> plone=app.Plone
>>> from zope.component.hooks import setSite
>>> setSite(plone)
>>> from plone import api
>>> prop = dict(fullname='ali khansari', location='Somewhere',)
>>> user = api.user.create(email='', username='ali', password='1234', properties=prop)
>>> api.user.grant_roles(username='ali',  roles=['Members'])
>>> import transaction
>>> transaction.commit()

Then when you have your code working with csv handling and everything create a .py file and execute it like that:

plone_daemon@ploneprod2:/usr/local/plone-5.1-latest/ploneprod$ bin/client_reserved run ~/ 


1 Like

It actually worked very well!!
thank you so much!

A nice add on for this is collective.mass_subscriptions.

it might need a small hack if you are using Plone 5.1, you could use this (if you only need to use it once):

I did a better hack, but for some reason I can not push to GitHub form OSX anymore
(if you dont send email you can use the 'Proper version' on pypi.