'reg_code' and 'code' are two terms used in invite.module to define the same thing in different places, but it would be easier for developers if the expected terminology was always the same.
For instance, I am working on a module to create a new successful invite when a new user registers, and I wanted to send an object through invite_save and invite_process. This would work fine except that one function expects 'code' and the other 'reg_code', but I realized I can define both.
So for example:
/**
* Implementation of hook_user().
*/
function invite_link_user($op, &$edit, &$account, $category = NULL) {
switch ($op) {
case 'insert':
if (isset($_SESSION[INVITE_LINK_SESSION])) {
$code = invite_generate_code();
$invite = _invite_substitutions(array(
'inviter' => $_SESSION[INVITE_LINK_SESSION],
'email' => $account->mail,
'reg_code' => $code, // works for invite_process()
'code' => $code, // works for invite_save()
));
invite_save($invite);
invite_process($invite, $account);
unset($_SESSION[INVITE_LINK_SESSION]);
$_SESSION[INVITE_SESSION] = $code;
}
break;
}
}
Comments
Comment #1
ryan osītis commented