Skip to content

Instantly share code, notes, and snippets.

@spraveenitpro
Created December 11, 2013 07:53
Show Gist options
  • Save spraveenitpro/7906530 to your computer and use it in GitHub Desktop.
Save spraveenitpro/7906530 to your computer and use it in GitHub Desktop.
WordPress Gist to display First Name in Registration Form
<?php
add_action('register_form','show_first_name' );
add_action('register_post','check_fields',10,3 );
add_action('user_register','register_extra_fields' );
function show_first_name () {
?>
<p>
<label>First Name </br>
<input type="text" id="user_email" size="25" value="<?php echo $_POST['first']; ?>" name="first">
</label>
</p>
<?php }
function check_fields($login,$email,$errors) {
global $firstname;
if($_POST['first']=='') {
$errors->add('empty_realname',"<strong>Error</strong>: Please Enter in First Name");
}
else {
$firstname = $_POST['first'];
}
}
function register_extra_fields($user_id,$password="",$meta=array()) {
$userdata = array();
$userdata['ID'] = $user_id;
$userdata['first_name'] = $_POST['first'];
wp_update_user( $userdata );
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment