If a user is invited to join the site, but they go straight to the site and sign up without using the invite link, the invitations for that user aren't processed. If invite_user('insert') doesn't find a reg code in the session, it could query the invite table by email address to see if one exists and use it. I actually made this patch to 2.x-dev and 1.12. There are probably corner cases that I'm not thinking of where this wouldn't work, but here it is to think about anyway.

Replace this:

function invite_user($op, &$edit, &$account, $category = NULL) {
switch ($op) {
case 'insert':
if ($invite = invite_load_from_session()) {

With this:

function invite_user($op, &$edit, &$account, $category = NULL) {
switch ($op) {
case 'insert':
$invite = invite_load_from_session();
if (!$invite) {
$reg_code = db_result(db_query("select reg_code from {invite} where email = '%s'", $account->mail));
if($reg_code) {
$invite = invite_load($reg_code);
}
}
if ($invite) {

Comments

vaelen’s picture

Whoops, forgot the code tags:

Replace this:

function invite_user($op, &$edit, &$account, $category = NULL) {
  switch ($op) {
    case 'insert':
      if ($invite = invite_load_from_session()) {

With this:

function invite_user($op, &$edit, &$account, $category = NULL) {
  switch ($op) {
    case 'insert':
      $invite = invite_load_from_session();
      if (!$invite) {
        $reg_code = db_result(db_query("select reg_code from {invite} where email = '%s'", $account->mail));
        if($reg_code) {
          $invite = invite_load($reg_code);
        }
      }
      if ($invite) {
smk-ka’s picture

Status: Active » Fixed

Sounds sane. Added to CVS, thanks a lot.
http://drupal.org/cvs?commit=100445

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.