Advertisement
Guest User

Registration number

a guest
Jul 12th, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. /**
  2. * Upon user registration, generate a random number and add this to the usermeta table
  3. *
  4. * @param required integer $user_id The ID of the newly registerd user
  5. */
  6. add_action(‘user_register’, ‘my_on_user_register’);
  7. function my_on_user_register($user_id){
  8.  
  9. $args = array(
  10. ‘length’ => 6,
  11. ‘before’ => date(“Y”)
  12. );
  13. $random_number = my_random_string($args);
  14. update_user_meta($user_id, ‘random_number’, $random_number);
  15.  
  16. }
  17.  
  18. /**
  19. * Output additional data to the users profile page
  20. *
  21. * @param WP_User $user Object properties for the current user that is being displayed
  22. */
  23. add_action(‘show_user_profile’, ‘my_extra_user_profile_fields’);
  24. add_action(‘edit_user_profile’, ‘my_extra_user_profile_fields’);
  25. function my_extra_user_profile_fields($user){
  26.  
  27. $random_number = get_the_author_meta(‘random_number’, $user->ID);
  28. ?>
  29. <h3><?php _e(‘Custom Properties’); ?></h3>
  30.  
  31. <table class=”form-table”>
  32. <tr>
  33. <th><label for=”address”><?php _e(‘Random Number’); ?></label></th>
  34. <td><?php echo $random_number; ?></td>
  35. </tr>
  36. </table>
  37. <?php
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement