如何在脚本中创建新的Joomla用户帐户? [英] How can I create a new Joomla user account from within a script?

查看:101
本文介绍了如何在脚本中创建新的Joomla用户帐户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在为Joomla创建XML API,允许合作伙伴网站在我们的网站上为其用户创建新帐户.

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

我们已经创建了一个独立的PHP脚本来处理和验证API请求,但是现在我们需要实际创建新帐户.最初,我们只是考虑进行CURL调用以提交注册表单,但我们意识到用户令牌存在问题.是否有另一种干净的方法可以创建用户帐户而不用担心Joomla?如果一定要做一些手术,什么是最好的方法呢?

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?

推荐答案

您应该使用Joomla内部类,例如JUser,因为其中存在许多内部逻辑,例如密码设置.创建一个使用API​​请求中的值的自定义脚本,并使用Joomla用户类中的方法将用户保存在数据库中.

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.

添加两种方式使用您的自定义代码的joomla用户是一个很棒的教程.该方法有效.我在某些项目中使用了这种方法.

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.

如果您必须访问Joomla Framework 外部 Joomla,请

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

这篇关于如何在脚本中创建新的Joomla用户帐户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆