We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

How do i add a new member with custom module?

Development and Programming

bmds's avatar
bmds
8 posts
14 years ago
bmds's avatar bmds

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?

       
Arrae Developer's avatar
Arrae Developer
27 posts
14 years ago
Arrae Developer's avatar Arrae Developer

Did you ever find a proper solution to this? I too am having the same dilemma of having to either include the member module files or insert directly to the DB and neither are very efficient or proper.

       
Man With A Peg's avatar
Man With A Peg
124 posts
14 years ago
Man With A Peg's avatar Man With A Peg

Same here. I have directly inserted users before when two-way synchronization was necessary. Looks like that is the best approach again…

       
bmds's avatar
bmds
8 posts
about 14 years ago
bmds's avatar bmds

Sorry for not replying sooner, for some reason i didn’t get a response notification. I had to bite the bullet and insert the users directly into the db as i started running into other issues with the register_member method. I can cope for this particular module as little else happens with users, however it wouldn’t scale if the module was on multiple sites.

If nothing else a lot more attention needs to be given to the internal APIs to bring them up to scratch

       
Arrae Developer's avatar
Arrae Developer
27 posts
about 14 years ago
Arrae Developer's avatar Arrae Developer

Ya I too ended up with a very coupled and hack solution.. In my case, I duplicated the members module and made all my modifications to the hooks and then deactivated the default members module in favor of my own. Now I have two plugins to maintain and worry about everytime i update the core, what fun </sarcasm>!

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.