Ask any question about WordPress here... and get an instant response.
Post this Question & Answer:
How can I add a custom field to the WordPress registration form?
Asked on Feb 16, 2026
Answer
To add a custom field to the WordPress registration form, you will need to use custom code to modify the registration process. This involves using hooks to insert your custom field and save its data.
<!-- BEGIN COPY / PASTE -->
// Add a custom field to the registration form
function my_custom_registration_field() {
?>
<p>
<label for="phone_number"><?php _e('Phone Number', 'mydomain') ?><br/>
<input type="text" name="phone_number" id="phone_number" class="input" value="<?php echo esc_attr($_POST['phone_number'] ?? ''); ?>" size="25" /></label>
</p>
<?php
}
add_action('register_form', 'my_custom_registration_field');
// Save the custom field data
function my_save_custom_registration_field($user_id) {
if (isset($_POST['phone_number'])) {
update_user_meta($user_id, 'phone_number', sanitize_text_field($_POST['phone_number']));
}
}
add_action('user_register', 'my_save_custom_registration_field');
<!-- END COPY / PASTE -->Additional Comment:
- Ensure you have a child theme or a custom plugin to add this code to avoid losing changes during updates.
- Use `sanitize_text_field()` to clean the input data before saving it to the database.
- You can retrieve the custom field data using `get_user_meta($user_id, 'phone_number', true);`.
- Consider using a plugin like "Profile Builder" if you prefer not to handle code.
Recommended Links:
