Here’s a WordPress plugin that will allow you to customize the user registration fields through extra hooks.
Download Custom User Registration plugin Download from WordPress
As taken from the readme
file:
Description
Customize the user registration page with additional validated fields. Hooks right into existing parts of the registration process.
Provides a number of hooks to allow further customization: fields, validation, email header/message/template, custom signup url (if used with other plugins like BuddyPress).
Works with anything using the regular WP register hooks, like BuddyPress and Prospress.
Installation
- Upload plugin folder
custom-user-access
to your plugins directory (/content/plugins/
) - Activate plugin
- Go to new admin page User Login – ABT and change the registration url, if needed.
Please note that this includes an instance of Singleton
and WP_Options_page
, both taken from the WP-Dev-Library plugin, so if you are also using that plugin please be aware of potential conflicts. This plugin checks for the existance of those classes before including files, so if you experience any issues you can remove those lines.
Frequently Asked Questions
How do I add extra fields?
- Use the hook
abt_custom_register_fields
. Append or replace items in the$fields
array with an array of attributes. - Specify validation with
data-validation
. See plugin file for examples of password and name fields. - Make sure that, if you’re providing default WP fields, that the field names are correct.
function YOUR_register_fields($fields){ $fields []= array('name'=>'user_url', 'type'=>'text', 'class'=>'input url', 'size'=>20, 'label'=>'Your Website', 'data-validation'=>'url'); $fields []= array('name'=>'aim', 'type'=>'text', 'class'=>'input social-client', 'size'=>20, 'label'=>'AIM', 'data-validation'=>'alphanumeric'); // set name required $fields[3]['data-validation'] = array('required', 'string'); return $fields; } add_filter('abt_custom_register_fields', 'YOUR_register_fields');
How do I change the email?
** Headers **:
function YOUR_register_email_headers($headers){ $headers []= 'Bcc:youremail@domain.com'; return $headers; } add_filter('abt_custom_register_email_headers', 'YOUR_register_email_headers');
** Template **: Just copy email-signup.tpl.php
from the plugin folder to your theme folder. Or use the hook abt_custom_login_email_templates
.
How do I customize my thank-you message?
On your custom thank-you page, add something like the following:
// check if we had a successful signup - indicated by a notification in session
$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : NULL;
if( false !== strpos($referer, 'action=register')
|| (
true === ABT_Custom_User_Access::flash_var('notification')
)){
?>
<p>Thank you for registering! Please check your email for a confirmation message.</p>
<?php
// clear the flash message
ABT_Custom_User_Access::flash_var(false);
}
Hooks
abt_custom_login_nometa
determine which fields are not treated as usermeta, but instead directly on user table format: pipe-separated, default ='|user_url|display_name|'
abt_custom_login_fields
add or remove additional login fieldsabt_custom_login_extra_validation
apply extra validation, return whether it has errors or not – uses $has_errors, $key, $attr, $postabt_custom_login_has_errors
do something with the errors instead of saving the fieldabt_custom_login_email_templates
adjust default template namesabt_custom_login_email_headers
change default email headersabt_custom_login_email_message
change email message before it’s sent to userabt_custom_register_url
change where the form redirects to on error; not completely working, so please rely on the admin option instead.abt_custom_register_admin_settings
add more admin settings (usingWP_Options_Page
class)