如何使用 ExpressionEngine 模块添加新成员?
我正在构建一个 ExpressionEngine 模块,该模块需要能够向系统添加新成员。核心模块似乎不是为第三方模块使用而构建的,这似乎给我留下了两种稍微有点老套的方法。
第一种是使用 Member 核心模块的 register_member 方法使用的方法:
function register_member()
{
if ( ! class_exists('Member_register'))
{
require PATH_MOD.'member/mod.member_register.php';
}
$MR = new Member_register();
foreach(get_object_vars($this) as $key => $value)
{
$MR->{$key} = $value;
}
$MR->register_member();
}
这似乎有点脏,因为我必须从我的自定义模块中找出到 mod.member_register.php 文件的正确路径。
第二种方法是将成员记录直接插入数据库,这似乎更糟糕,因为我将避免创建成员的所有现有代码。这两种方法似乎都不是那么干净,有人能提出更好的方法吗?
I am building an ExpressionEngine module that will need the ability to add new members to the system. The core modules don't seem to be built to be used by third party modules, which seems to leave me with two slightly hacky approaches.
The first is to use the approach that the register_member method of the Member core module uses:
function register_member()
{
if ( ! class_exists('Member_register'))
{
require PATH_MOD.'member/mod.member_register.php';
}
$MR = new Member_register();
foreach(get_object_vars($this) as $key => $value)
{
$MR->{$key} = $value;
}
$MR->register_member();
}
This seems to be slightly dirty as i would have to work out the proper route to the mod.member_register.php file from my custom module.
The second approach is to insert the member record directly into the database which seems worse as i would be avoiding all of the existing code for creating members. Neither of these approaches seem to be that clean, can anyone suggest a better approach?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会对重用或包含 ExpressionEngine 自己的成员模块功能持谨慎态度,因为 自由职业者许可证< /a> 不包含任何成员管理功能...因此要求可能不存在的文件并不是一个好主意。
此外,EllisLab 在 EE 2.2 开发者预览版公告中表示,今后它们将将更加严格地执行公共/私有/受保护的类变量和方法。
我完全同意——更不用说这可能会绕过注册新用户时发生的许多内置条件和安全检查。
顺便说一句,Solspace 用户模块提供了注册新用户的功能成员来自控制面板外部,因此该功能之前已由模块完成。
这是一个很好的问题,可以通过将其发布到更多 ExpressionEngine 开发人员可以看到的地方来更好地回答 - 例如,在 ExpressionEngine Pro 网络讨论论坛 或开发和编程论坛。
I would be wary of reusing or including ExpressionEngine's own Member Module functionality, since the Freelancer License doesn't include any Member Management capabilities ... so requiring a file that may not exist isn't such a good idea.
Furthermore, EllisLab stated in the EE 2.2 Developer Preview announcement that going forward they are going to be more strict on enforcing public/private/protected class vars and methods.
I couldn't agree more — not to mention this may circumvent many of the built-in conditional and security checks that occur when registering new users.
On a side note, The Solspace User Module offers the ability to register new members from outside the Control Panel, so the functionality has been accomplished by a Module before.
This is a great question, and can be better answered by posting it where more ExpressionEngine Developers may see it — for example, in the ExpressionEngine Pro Network Discussion forum or in the Development and Programming forum.