I would like the ability to create one-time use codes, whereby once a user has registered with that code, it can no longer be used. I don't want users to be able to share their code with other users who aren't supposed to be able to register or to be able to create multiple accounts.

I described a possible new module here: http://drupal.org/node/150756. However, I may be able to (less efficiently) use the Registration Code module to achieve what I'm trying to do by first having a webform that the user fills out with their mailing address and then I mail them a Registration Code that they can use to register on the site.

Comments

bakwas_internet’s picture

Status: Active » Needs review

Did some hacking and finally came up with following code. This is working fine on my system. Can other people test it and give me their feedback.


     if (!in_array(trim($edit['regcode_code']), $regcodes)) {
            form_set_error('regcode_code', t('Invalid registration code'));
            watchdog('regcode', t('User entered invalid registration code: ') .
            $edit['regcode_code'], WATCHDOG_WARNING);
          }
          // code to remove the reg code which has been used once
          else
          {
          	$removekey= array_search(trim($edit['regcode_code']), $regcodes);
          	unset ($regcodes[$removekey]);
          	$regcodestring= join("\n",$regcodes);
          	variable_set('regcode_codes',$regcodestring);
          }
        }
        break;
colan’s picture

Version: 5.x-1.0 » 5.x-1.x-dev
Status: Needs review » Closed (duplicate)

This is a duplicate of http://drupal.org/node/154355.