Creating Custom Front End Registration for wordpress

Front end registration form that allow your users to signup without ever leaving your main site, you provide a much more consistent and comfortable environment. Registration form has basic following fields.

  • Username
  • Email
  • First Name
  • Last Name
  • Password

Processing Our Registration Form Data

$fname=$_POST['first_name'];
	$lname=$_POST['last_name'];
	$user_name=$_POST['username'];
	$email=$_POST['email'];
	$pass=$_POST['password'];
	$userdata = array(
			'user_login' => $user_name,
			'user_email' => $email,
			'user_pass' =>$pass,
			'first_name' =>$fname,
			'last_name' =>$lname,
);
$user_id = wp_insert_user( $userdata ) ;
if($user_id) {
wp_new_user_notification($user_id);
wp_setcookie($user_name, $pass, true);
wp_set_current_user($user_id, $user_name);	
do_action('wp_login', $user_name);
$url=get_bloginfo('url')."/pagename";
wp_redirect($url);
	exit();
}

1. Make sure that a username has been entered and that the nonce verifies, to confirm the form has been submitted from the correct location.

2. Each of the posted variables (username, email, password, etc) will be assigned to a variable.

3. The core registration.php file will be loaded into our function. Without it, we cannot perform many of the validation checks needed.

4. The entered username will be compared against the database to make sure it has not already been registered by a different user.

5. The entered username will be checked to make sure it is valid, in terms of characters used, length, etc.

6. The entered username is checked to make sure it is not blank.

7. The entered email is checked to ensure it is a valid email.

8. The entered email is checked against the database to ensure it is not already registered.

9. The entered password is checked to ensure it is now blank.

10. The entered password is checked against the confirm password to ensure the user has entered their password correctly.