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

查看:14
本文介绍了如何从脚本中创建新的 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 访问 Joomla 框架,检查此资源.

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

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

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