Michael Rog presents

RogEE: Add-ons for ExpressionEngine 2

Registration Codes 1.1.0

Verifies new registrations and places users into predefined member groups based on customizable invite/registration codes.

Fight registration spam with custom registration codes!

Using the Registration Codes extension, you can create codes to place users to register directly into a pre-determined member group.

Optionally, you can require a valid code for new member registration. (i.e. You can restrict new sign-ups on your site to be allowed only with a valid invitation code.

MSM-compatible!

With the EE Multiple Site Manager active, you can specify registration codes for each individual sites or for all sites globally.

3 Useful Ways to Use Registration Codes

  1. Simple registration code: Add a single text input to your registration form to verify new users and/or place them into a member group you have chosen.
  2. Self-selected member groups: Add a drop-down select box or radio button input to the registration form to allow new members to choose their destination group from a pre-defined list.
  3. Store codes in a custom field: Permanently archive the code someone uses to register for your site by using a custom member field.

Example #1 - Simple Registration Code

  1. Navigate to the Extensions page in your CP and activate the Registration Codes extension.
  2. Go to the Settings page for the Registration Codes extension, and choose a name for the form field you'll use to track registration codes submitted by your users. The default value is registration_code. Enter your chosen field name into the Form field [name] box and save the settings.
  3. Now, you need to create a form field of that same name on your member registration page. The default member theme is in the themes/profile_themes/default directory, and the file you need to edit is called registration_form.html.
  4. Add the form field HTML. For example, to add a text box below the CAPTCHA field in the default template, your code will be similar to this:
    {if captcha}
    <p><span class="highlight">*</span> {lang:captcha}</p>
    <p>
    {captcha}
    <br />
    <input type="text" name="captcha" value=""
       size="20" maxlength="20" style="width:140px;" />
    </p>
    {/if}
    <p>Registration code</p>
    <p><input type="text" name="registration_code" value=""
       size="20" maxlength="100" style="width:140px;" /></p>
    
  5. Note: The name attribute of the form field must match the Form field [name] setting in the Registration Codes extension CP.
  6. When a new registration is processed, if the value submitted in this form field matches a registration code you have set up in the CP, the new member will be placed into the corresponding destination group.

Example #2 - Self-selected member groups

Perhaps you'd like to give your users the ability to self-select between member groups. For example, if you have BOY and GIRL groups, you can let users choose which group they're placed into when they register.

This example is similar to Example #1, except that we'll use radio buttons instead of a text input.

  1. Navigate to the Extensions page in your CP and activate the Registration Codes extension.
  2. Go to the Settings page for the Registration Codes extension, and choose a name for the form field you'll use to track registration codes submitted by your users. The default value is registration_code. Enter your chosen field name into the Form field [name] box and save the settings.
  3. Now, you need to create a form field of that same name on your member registration page. The default member theme is in the themes/profile_themes/default directory, and the file you need to edit is called registration_form.html.
  4. Add the radio buttons HTML. For example, to add radio buttons below the CAPTCHA field in the default template, your code will be similar to this:
    {if captcha}
    <p><span class="highlight">*</span> {lang:captcha}</p>
    <p>
    {captcha}
    <br />
    <input type="text" name="captcha" value=""
       size="20" maxlength="20" style="width:140px;" />
    </p>
    {/if}
    <p>Select your group</p>
    <p>
    <input type="radio" name="registration_code" value="boys" /> Boys<br />
    <input type="radio" name="registration_code" value="girls" /> Girls
    </p>
    
  5. Note: The name attribute of the radio buttons must match the Form field [name] setting in the Registration Codes extension CP.
  6. Note: You must create the boys and girls registration codes in the extension CP.

Example #3 - Registration codes in custom member fields

Perhaps you'd like to permanently store the registration codes used to register for your site. (For example, you might want to make special content available in your templates for members who used a particular invitation code, but you don't want to set up unique member groups for them.)

In this case, we can use ExpressionEngine's built-in Custom Member Fields feature.

  1. First, create a custom member field to keep track of registration/invite codes. Make sure this new field is set to be visible in the registration form. At your discretion, you can keep it hidden on member profile pages.
  2. Note the Field ID of the Custom Member Field you just created. (We'll use this number in a moment.)
  3. Navigate to the Extensions page in your CP and activate the Registration Codes extension.
  4. Go to the Settings page for the Registration Codes extension.
  5. ExpressionEngine will auto-generate the form field for your Custom Member Field when the registration form is displayed. The name of the form field will use the Field ID of the Custom Member Field: For example, the form field name for Custom Member Field 1 is m_field_id_1. Enter the appropriate field name into the Form field [name] box and save the settings.
  6. When a new registration is processed, your specified Custom Member Field will be searched for a valid code as in Example #1. In addition, if the registration completes, the code will be stored in the Custom Member Field for that user.

Other possibilities

The extension is designed to be flexible: You can use any form field on the registration form. The possibilities are endless! If you have questions or suggestions about other possible use cases, please create a comment on the GetSatisfaction page.

Note on Self-activation via email

The registration code is processed using the POST data from the registration form, which is only available during the initial member creation process. For this reason, Registration Codes does not fully support Self-activation via email. The extension will work to require a valid registration code when a new member is registering, but it won't work to assign that member to a special group if they self-activate by email.

In order to take advantage of special member assignments according to registration codes, Require Member Account Activation? should be set to No Activation Required.