Add Birthday Field to “Add New User”
-
I added a function to give my registered users the ability to update their birthdays in their profiles. I also have a birthday field users register as a member:
/**
* The field on the editing screens.
*
* @param $user WP_User user object
*/
function wporg_usermeta_form_field_birthday($user)
{
?>
<h3>Your Birthday</h3>
<table class=”form-table”>
<tr>
<th>
<label for=”birthday”>Birthday</label>
</th>
<td>
<input type=”date”
class=”regular-text ltr”
id=”birthday”
name=”birthday”
value=”<?= esc_attr(get_user_meta($user->ID, ‘birthday’, true)); ?>”
title=”Please use YYYY-MM-DD as the date format.”
pattern=”(19[0-9][0-9]|20[0-9][0-9])-(1[0-2]|0[1-9])-(3[01]|[21][0-9]|0[1-9])”
required>
<p class=”description”>
Please enter your birth date.
</p>
</td>
</tr>
</table>
<?php
}/**
* The save action.
*
* @param $user_id int the ID of the current user.
*
* @return bool Meta ID if the key didn’t exist, true on successful update, false on failure.
*/
function wporg_usermeta_form_field_birthday_update($user_id)
{
// check that the current user have the capability to edit the $user_id
if (!current_user_can(‘edit_user’, $user_id)) {
return false;
}// create/update user meta for the $user_id
return update_user_meta(
$user_id,
‘birthday’,
$_POST[‘birthday’]
);
}// add the field to user’s own profile editing screen
add_action(
‘edit_user_profile’,
‘wporg_usermeta_form_field_birthday’
);// add the field to user profile editing screen
add_action(
‘show_user_profile’,
‘wporg_usermeta_form_field_birthday’
);// add the save action to user’s own profile editing screen update ftp://ftp.invitation-fascination.com//latinocosociety/wp-content/uploads/gravity_forms/id
add_action(
‘personal_options_update’,
‘wporg_usermeta_form_field_birthday_update’
);// add the save action to user profile editing screen update
add_action(
‘edit_user_profile_update’,
‘wporg_usermeta_form_field_birthday_update’
);The problem is if I add a new user manually I get this message because there is no birthday field in “Add New User”
bool(false) string(5) “Y-m-d” NULL
Warning: Cannot modify header information – headers already sent by (output started at /home1/invitav6/public_html/latinocosociety/wp-content/plugins/birthdays-widget/birthday-widget.php:146) in /home1/invitav6/public_html/latinocosociety/wp-includes/pluggable.php on line 1210Can you tell me if there’s a way to add a birthday field to the “Add New User” page?
The page I need help with: [log in to see the link]
- The topic ‘Add Birthday Field to “Add New User”’ is closed to new replies.