Edit: Add profile field (usermeta) to user registration
I am trying to add a custom field to the Add New User page much as I have done with the user profile page like so:
add_action( 'show_user_profile', 'my_show_extra_profile_fields' );
add_action( 'edit_user_profile', 'my_show_extra_profile_fields' );
function my_show_extra_profile_fields( $user ) { ?>
<h3>Player information</h3>
<table class="form-table">
<tr>
<th><label for="team-meta">Team Name</label></th>
<td>
<?php
$status = get_the_author_meta( 'team-meta', $user->ID );
$items = get_posts (array (
'post_type' => 'team_page',
'posts_per_page' => -1
));
echo '<select name="team-meta" id="team-meta">
<option value="">No team selected</option>';
foreach($items as $item) {
echo '<option value="'.$item->ID.'"',$status == $item->ID ? ' selected="selected"' : '','>'.$item->post_title.'</option>';
} // end foreach
?>
<span class="description">Please enter the player's team name </span>
</td>
</tr>
</table>
<?php }
add_action( 'personal_options_update', 'my_save_extra_profile_fields' );
add_action( 'edit_user_profile_update', 'my_save_extra_profile_fields' );
function my_save_extra_profile_fields( $user_id ) {
if ( !current_user_can( 'edit_users', $user_id ) )
return false;
update_user_meta( $user_id, 'team-meta', $_POST['team-meta'] );
}
Basically I want whoever creates a new user to be able to add this directly without going to the user profile.