How can I create a new Joomla user account from within a script?

user77413 picture user77413 · Dec 15, 2009 · Viewed 48.7k times · Source

We're creating an XML API for Joomla that allows partner sites to create new accounts for their users on our website.

We've created a standalone PHP script that processes and validates the API request, but now we need to actually create the new accounts. We were originally thinking about just doing a CURL call to submit the signup form, but we realized that there is an issue with the user token. Is there another clean way to create a user account without going into the guts of Joomla? If we do have to do some surgery, what is the best way to approach it?

Answer

GmonC picture GmonC · Dec 15, 2009

You should use Joomla internal classes, like JUser, since there a lot of internal logic such as password salting. Create a custom script that uses the values from the API request and saves the users in the database using methods from Joomla User Classes.

Two ways to add joomla users using your custom code is a wonderful tutorial. The approach works. I've used this approach in some projects.

If you have to access Joomla Framework outside Joomla, check this resource instead.