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?
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
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>!
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.