Require Additional Profile Fields at Registration

<?php

add_action( 'register_form', 'additional_profile_fields' );
function additional_profile_fields() { ?>
    <p>
        <label><?php _e('First Name') ?><br />
        <input type="text" name="first_name" id="first_name" class="input" size="25" tabindex="20" /></label>
    </p>
    <p>
        <label><?php _e('Last Name') ?><br />
        <input type="text" name="last_name" id="last_name" class="input" size="25" tabindex="20" /></label>
    </p>
<?php }
 
add_action( 'register_post', 'add_register_field_validate_first_name', 10, 3 );
function add_register_field_validate_first_name( $sanitized_user_login, $user_email, $errors) {
    if (!isset($_POST[ 'first_name' ]) || empty($_POST[ 'first_name' ])) {
    	return $errors->add( 'firstnameempty', '<strong>ERROR</strong>: Please provide a first name.' );
    }    
}
add_action( 'register_post', 'add_register_field_validate_last_name', 10, 3 );
function add_register_field_validate_last_name( $sanitized_user_login, $user_email, $errors) {
    if (!isset($_POST[ 'last_name' ]) || empty($_POST[ 'last_name' ])) {
    	return $errors->add( 'lastnameempty', '<strong>ERROR</strong>: Please provide a last name.' );
    }    
}

add_action( 'user_register', 'insert_register_fields' );
function insert_register_fields( $user_id ) {
	
	$first_name = apply_filters('pre_user_first_name', $_POST['first_name']);
	$last_name = apply_filters('pre_user_last_name', $_POST['last_name']);
	
	update_user_meta( $user_id, 'first_name', $first_name );
	update_user_meta( $user_id, 'last_name', $last_name );
}

Change “Register” Link to “Sign Up”

Very similar to a previous post about the “Log In” links, but for the “Register” link. If you think your users would be more comfortable with different verbiage, then make your users comfortable:

add_filter( 'register', 'reg2sign' );
function reg2sign( $link ) {
	$link = str_replace( '>Register<', '>Sign Up<', $link );
	return $link;
}

Extra Username Validation

Run a family-friendly site and want to make sure no inappropriate words end up in usernames? Use this

add_filter( 'validate_username', 'forbidden_username_terms', 10, 2);
function forbidden_username_terms($valid, $username) {
	$badwords = array('badword','nogood');
	foreach($badwords as $bw) {
		if (strpos($username,$bw) !== false) return false; 
	}
	return $username;
}

Add A Security Question to the Register Screen

Want to allow people to register on your site, but don’t want to be flooded with spam users? Try this:

add_action( 'register_form', 'add_register_field' );
function add_register_field() { ?>
	<p>
		<label><?php _e('What is the name of the ship in the TV show Firefly?') ?><br />
		<input type="text" name="user_proof" id="user_proof" class="input" size="25" tabindex="20" /></label>
	</p>
<?php }

add_action( 'register_post', 'add_register_field_validate', 10, 3 );
function add_register_field_validate( $sanitized_user_login, $user_email, $errors) {
	if (!isset($_POST[ 'user_proof' ]) || empty($_POST[ 'user_proof' ])) {
		return $errors->add( 'proofempty', '<strong>ERROR</strong>: You did not answer the proof-of-humanship question.'  );
	} elseif ( strtolower( $_POST[ 'user_proof' ] ) != 'serenity' ) {
		return $errors->add( 'prooffail', '<strong>ERROR</strong>: You did not answer the proof-of-humanship question correctly.'  );
	}
}

This adds an extra box to the register screen with the question “What is the name of the ship in the TV show Firefly?” The user-provided answer is then compared to the official answer. If correct, the user is registered, otherwise WordPress-friendly error(s) are returned.