Add custom or extra fields on registration page in wordpress

Open your theme’s function.php file and drag this PHP code in.


// This function shows the form fiend on registration page



// This is a check to see if you want to make a field required



// This inserts the data

add_action(‘user_register’, ‘register_extra_fields’);


// This is the forms The Two forms that will be added to the wp register page

function show_first_name_field(){



<label>Hotel/Business<br />

<input id=”user_email” class=”input” type=”text” name=”hname” value=”<?php echo $_POST[‘hname’]; ?>” />





<label>Hotel Location<br />

<textarea id=”user_email” class=”input” type=”text” name=”first”><?php echo $_POST[‘first’]; ?></textarea>






// This function checks to see if they didn’t enter them

// If no first name or last name display Error

function check_fields($login, $email, $errors) {

global $firstname, $lastname;

if ($_POST[‘hname’] == ”) {

$errors->add(’empty_realname’, “<strong>ERROR</strong>: Please Enter the Hotel Name”);

} else {

$firstname = $_POST[‘hname’];


if ($_POST[‘first’] == ”) {

$errors->add(’empty_realname’, “<strong>ERROR</strong>: Please Enter the Hotel Location”);

} else {

$firstname = $_POST[‘first’];




// This is where the magiv happens

function register_extra_fields($user_id, $password=””, $meta=array())  {


// Gotta put all the info into an array

$userdata = array();

$userdata[‘ID’] = $user_id;


// Enters into DB

// wp_update_user($userdata);


// This is for custom meta data “gender” is the custom key and M is the value

update_usermeta($user_id, ‘twitter’,$_POST[‘first’]);

update_usermeta($user_id, ‘hname’,$_POST[‘hname’]);




Bansal Sumit

To seek challenging roles and to achieve excellence in the field of Open Source Web Technology with a profound spirit of commitment and dedication.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.