Example Code in PHP how to Create a new User

Hi all,

I’ve got an existing User DB and I simply want to push the User into the discourse Forum. My programming language is PHP and I know how to use curl but are there any examples, how to push a new user into discourse?

That would help me a lot.

Thanks! Frank

Wouldn’t it be easier to use import script? This importer can be an excellent base to make your own, just change DB table and row names from PHPBB’s to yours, and comment out anything that is not user-related: Importing from phpBB3 :slight_smile:


Hm, I don’t have shell access to discourse because it is maintained by someone else.

Okay, got it.
As the docs.discourse.org states, you have to make a POST request to the address yourforum/users with this fields:

  "name": "string",
  "email": "string",
  "password": "string",
  "username": "string",
  "active": true,
  "approved": true,
  "user_fields[1]": "string"

In this request, fields that you have to send are: name, email, password and username.
As this is a POST request, even simple HTML form should be enough, if I understand well :slight_smile:

1 Like

An import script is usually the easiest way to import users.

But they’ll give you an API key for the site?

Do you have admin access? Is it a new community or are there existing posts? Could you do the import and restore a backup?

One solution might just be to do a bulk invite.

1 Like