We've Always Got Something to Say.

Read our thoughts on what's happening in the industry.

January 19 , 2012

WordPress – Custom Registration Page

by

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

  1. Upload plugin folder custom-user-access to your plugins directory (/wp-content/plugins/)
  2. Activate plugin
  3. 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

  1. 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|'
  2. abt_custom_login_fields add or remove additional login fields
  3. abt_custom_login_extra_validation apply extra validation, return whether it has errors or not – uses $has_errors, $key, $attr, $post
  4. abt_custom_login_has_errors do something with the errors instead of saving the field
  5. abt_custom_login_email_templates adjust default template names
  6. abt_custom_login_email_headers change default email headers
  7. abt_custom_login_email_message change email message before it’s sent to user
  8. abt_custom_register_url change where the form redirects to on error; not completely working, so please rely on the admin option instead.
  9. abt_custom_register_admin_settings add more admin settings (using WP_Options_Page class)

About the Author

Jeremy Schwartz is a software developer with a broad range of programming experience from research, consulting, and academic settings. His favorite thing to do is refactor inefficient code into well-documented, elegant solutions using content-management systems and custom code. Or read books. Lots of books.

Leave a Reply

 

In a Nutshell

Since 1998, Atlantic BT has been a full service web development company that offers the tools, resources and services to get your business moving. We focus on combining new ideas, specific requirements, and years of experience into high-quality, results-oriented web solutions for small to medium sized businesses. If you want the best website possible that generates real results, let's get started.

Atlantic Business Technologies, Inc.
4509 Creedmoor Road, 3rd Floor
Raleigh, North Carolina 27612
  • Pinnacle Business Award Winner
  • Triangle Business Journal's Top 40 Under 40
  • Yahoo Search Marketing Ambassador
  • Google Adwords Qualified Company