如何使用 ExpressionEngine 模块添加新成员?

发布于 2024-11-15 17:40:56 字数 632 浏览 3 评论 0原文

我正在构建一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

那小子欠揍 2024-11-22 17:40:56

第一种方法是使用的 register_member 方法
成员模块使用 [...]

我会对重用或包含 ExpressionEngine 自己的成员模块功能持谨慎态度,因为 自由职业者许可证< /a> 不包含任何成员管理功能...因此要求可能不存在的文件并不是一个好主意。

此外,EllisLab 在 EE 2.2 开发者预览版公告中表示,今后它们将将更加严格地执行公共/私有/受保护的类变量和方法。

第二种方法是插入
会员记录直接存入
数据库似乎比我想的更糟糕
避免所有现有代码
用于创建成员。

我完全同意——更不用说这可能会绕过注册新用户时发生的许多内置条件和安全检查。

顺便说一句,Solspace 用户模块提供了注册新用户的功能成员来自控制面板外部,因此该功能之前已由模块完成。

这两种方法似乎都不是
很干净,任何人都可以推荐一个
更好的方法?

这是一个很好的问题,可以通过将其发布到更多 ExpressionEngine 开发人员可以看到的地方来更好地回答 - 例如,在 ExpressionEngine Pro 网络讨论论坛开发和编程论坛

The first approach is to use the the register_member method of the
Member Module uses [...]

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.

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.

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.

Neither of these approaches seem to be
that clean, can anyone suggest a
better approach?

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文