Stand-Alone Member Register
This module enables you to display members registration form within your EE templates. Using it, you can give any look to your registration form, give it any URL address and use all power of EE tags.
All registration processing relies on Member module so all your extensions will be working.
You need to have Member module present on your system
- Installation
- Usage
- Adding CAPTCHA
- Displaying custom fields
- Specifying return page
- AJAX registration
- Example
Installation
For EE 1.x, place the directory contained in zip into your /system/modules directory. For EE 2.x, place it into your /system/expressionengine/third_party directory. Then go to 'Modules' section in your Control Panel and perform installation.
Usage
{exp:sa_member_register:form} is the only tag you need. Just wrap anything you want to be displayed in the form inside the tag pair.
You will need at least following fields for the registration to work:
username
password
password_confirm
email
Besides, depending on your settings, you might need accept_terms checkbox, captcha input, or custom fields.
You can spacify the id, class and name parameter for html form using following parameter for EE tag:
id="my_id"
class="my_class"
name="my_name"
Adding CAPTCHA
{captcha} variable will be replaced with actual CAPTCHA image. If you have any related extensions, they should be working here as well (but needs testing with each individual extension).
You can wrap all related text/markup inside {if captcha}{/if} conditional, so that if will be displayed only if you have CAPTCHA on in your settings.
Specifying return page
If you want the module to make redirect to certain page after submitting message about successfule registration, you can add the return="site/template" parameter to the form - but also you'll have to add some hacks to the code. This is necessary because the add-on relies on EE Member module.
So, open the file /modules/member/mod.member_register.php and at the end of register_member() function find lines that look like
$data = array( 'title' => $LANG->line('mbr_registration_complete'), 'heading' => $LANG->line('thank_you'), 'content' => $LANG->line('mbr_registration_completed')."\n\n".$message, 'redirect' => '', 'link' => array($return, $site_name) );and replace them with
$return = ($_POST['RET']!='')?$_POST['RET']:$PREFS->ini('site_url'); $data = array( 'title' => $LANG->line('mbr_registration_complete'), 'heading' => $LANG->line('thank_you'), 'content' => $LANG->line('mbr_registration_completed')."\n\n".$message, 'redirect' => $return, 'link' => array($return, $site_name), 'rate' => 5 );
If you're using EE2, the lines will look like
$data = array( 'title' => $this->EE->lang->line('mbr_registration_complete'), 'heading' => $this->EE->lang->line('thank_you'), 'content' => $this->EE->lang->line('mbr_registration_completed')."\n\n".$message, 'redirect' => '', 'link' => array($return, $site_name) );and
$return = ($_POST['RET']!='')?$_POST['RET']:$this->EE->config->item('site_url'); $data = array( 'title' => $this->EE->lang->line('mbr_registration_complete'), 'heading' => $this->EE->lang->line('thank_you'), 'content' => $this->EE->lang->line('mbr_registration_completed')."\n\n".$message, 'redirect' => $return, 'link' => array($return, $site_name), 'rate' => 5 );
Displaying custom fields
If you want to add custom profile fields to your registration form, you can either add html manually (you should use 'technical' field names in this case, as they appear in database, e.g. m_field_id_12) or use {custom_fields} tag pair.
Inside {custom_fields} tag are available following variables and conditionals:
- field_label - field label / readable name
- field_description - field description
- field_name - 'technical' field name, to be used with <input> tag
- width - field width
- maxlength - field max length
- rows - number fo of rows (for textarea)
- options - pre-populated options list for drop-down inputs
- if required - display text/html if the field is required
- if text - display text/html if the field type is text input
- if textarea - display text/html if the field type is textarea
- if select - display text/html if the field type is dropdown select
AJAX registration
You can process your member registration using AJAX (i.e. without page reload). To do this, add ajax="yes" parameter to {exp:sa_member_register:form} tag.
Then, use following variables inside your form (each one is optional):
{error_container} — will create a container that will display error message (if any). Place it whereever you want error messages to appear (it is hidden initially)
{loader}Please wait...{/loader} — will display 'loading' message when form is submitted. Replace the contents with appropriate image and/or text
If the registration has been successful, the form will be replaced with system success message.
You can also optionally add post_process parameter to form tag — JavaScript function(s) that will be executed after successful login. Separate multiple functions with pipe, ex. post_process="function1|function2|function3"
Example
{exp:sa_member_register:form id="register_form" class="form"}
<p>Username: <input type="text" name="username" /></p>
<p>Screen name: <input type="text" name="screen_name" /></p>
<p>Password: <input type="text" name="password" /></p>
<p>Confirm password: <input type="text" name="password_confirm" /></p>
<p>Email: <input type="text" name="email" /></p>
{custom_fields}
<p>{field_label}{if required}*{/if}:
{if text}
<input type="text" name="{field_name}" width="{width}" maxlength="{maxlength}" />
{/if}
{if textarea}
<textarea name="{field_name}" rows="{rows}"></textarea>
{/if}
{if select}
<select name="{field_name}">{options}</select>
{/if}
</p>
{/custom_fields}
{if captcha}
<p>CAPTCHA: <input type="text" name="captcha" /></p>
{captcha}
{/if}
<p><input type="checkbox" value="y" name="accept_terms" /> I agree to the terms of service</p>
<input type="submit" />
{/exp:sa_member_register:form}