"Manually" create new users

Hey there,
I’m using Ghost and I find it very user-friendly and powerful, it’s a very well-designed product.
One thing I don’t understand is how I can “manually” create users, in the sense that I want to insert records in the database without using the “invite” button.
I know it’s not recommended but a customer asked if I could implement it (and strictly requires something like this).

I already came up with this solution:
INSERT INTO users (id, name, slug, password, email, created_at, created_by) VALUES(...)
and then I would insert the id in the roles_users table.
I noticed (as mentioned in this topic) that Ghost outputs Validation (matches) failed for id as soon as I try do edit something because I’m not generating a valid ObjectID.
What exactly is an ObjectID?
How can I generate it?

Thanks in advance.

So to be clear, it’s not recommended to modify the database directly, if you’re self hosting you might be better off adding/changing at the api level in order to create users via the model.

However, if you do need to do it this way, you can use https://www.npmjs.com/package/bson-objectid to generate ObjectID’s :slight_smile:

1 Like

Thanks a lot, really appreciate it.
Keep up the good work with Ghost!

1 Like