Skip to content

Instantly share code, notes, and snippets.

@nayemDevs
Created October 19, 2016 17:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nayemDevs/760095904a4e24b422bbdcf487fc2cff to your computer and use it in GitHub Desktop.
Save nayemDevs/760095904a4e24b422bbdcf487fc2cff to your computer and use it in GitHub Desktop.
Extra Field For WordPress Registration
/* Showing the extra field on the registration form */
add_action('register_form', 'new_register_field');
function new_register_field() {
?>
<p>
<label for="first_name"><?php _e('First Name') ?><br />
<input type="text" name="first_name" id="first_name" class="input" value="<?php echo esc_attr($_POST['first_name']); ?>" size="25" tabindex="20" />
</label>
</p>
<p>
<label for="last_name"><?php _e('Last Name') ?><br />
<input type="text" name="last_name" id="last_name" class="input" value="<?php echo esc_attr($_POST['last_name']); ?>" size="25" tabindex="20" />
</label>
</p>
<?php
}
/* Save those extra filed on the user profile area*/
add_filter('pre_user_first_name', 'user_first_name_wlx');
add_filter('pre_user_last_name', 'user_last_name_wlx');
function user_first_name_wlx($first_name) {
if (isset($_POST['first_name'])) {
$first_name = $_POST['first_name'];
}
return $first_name;
}
function user_last_name_wlx($last_name) {
if (isset($_POST['last_name'])) {
$last_name = $_POST['last_name'];
}
return $last_name;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment