I have to create a membership site, but I need to give every user that registers a automatic ID number.
For example,
User 2 - has a code - pay-102
User 3 - has a code - pay-103
I did a forum search and found this, its pretty much what I am asking - What is the fastest way to generate a unique id number when registering a user
I've got a piece of code that will add it to the user panel in the admin area:
function fb_add_custom_user_profile_fields( $user ) {
?>
<h3><?php _e('Extra Profile Informations', 'themename'); ?></h3>
<table class="form-table">
<tr>
<th>
<label for="memnumber"><?php _e('memnumber', 'themename'); ?>
</label></th>
<td>
<input type="text" name="memnumber" id="memnumber" value="<?php echo esc_attr( get_the_author_meta( 'memnumber', $user->ID ) ); ?>" class="regular-text" /><br />
<span class="description"><?php _e('Please enter your Membership number.', 'themename'); ?></span>
</td>
</tr>
</table>
<?php }
function fb_save_custom_user_profile_fields( $user_id ) {
if ( !current_user_can( 'edit_user', $user_id ) )
return FALSE;
update_usermeta( $user_id, 'memnumber', $_POST['memnumber'] );
}
add_action( 'show_user_profile', 'fb_add_custom_user_profile_fields' );
add_action( 'edit_user_profile', 'fb_add_custom_user_profile_fields' );
add_action( 'personal_options_update', 'fb_save_custom_user_profile_fields' );
add_action( 'edit_user_profile_update', 'fb_save_custom_user_profile_fields' );
How do I populate that field, with an incremental number that is assigned?