Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. add_action( 'show_user_profile', 'yoursite_extra_user_profile_fields' );
  2. add_action( 'edit_user_profile', 'yoursite_extra_user_profile_fields' );
  3. function yoursite_extra_user_profile_fields( $user ) {
  4. ?>
  5. <h3><?php _e("Extra profile information", "blank"); ?></h3>
  6. <table class="form-table">
  7. <tr>
  8. <th><label for="phone"><?php _e("Phone"); ?></label></th>
  9. <td>
  10. <input type="text" name="phone" id="phone" class="regular-text"
  11. value="<?php echo esc_attr( get_the_author_meta( 'phone', $user->ID ) ); ?>" /><br />
  12. <span class="description"><?php _e("Please enter your phone."); ?></span>
  13. </td>
  14. </tr>
  15. </table>
  16. <?php
  17. }
  18.  
  19. add_action( 'personal_options_update', 'yoursite_save_extra_user_profile_fields' );
  20. add_action( 'edit_user_profile_update', 'yoursite_save_extra_user_profile_fields' );
  21. function yoursite_save_extra_user_profile_fields( $user_id ) {
  22. $saved = false;
  23. if ( current_user_can( 'edit_user', $user_id ) ) {
  24. update_user_meta( $user_id, 'phone', $_POST['phone'] );
  25. $saved = true;
  26. }
  27. return true;
  28. }
  29.  
  30. // remove aim, jabber, yim
  31. function hide_profile_fields( $contactmethods ) {
  32. unset($contactmethods['aim']);
  33. unset($contactmethods['jabber']);
  34. unset($contactmethods['yim']);
  35. return $contactmethods;
  36. }
  37.  
  38. // add anything else
  39. function my_new_contactmethods( $contactmethods ) {
  40. //add Birthday
  41. $contactmethods['birthday'] = 'Birthday';
  42. //add Address
  43. $contactmethods['address'] = 'Address';
  44. //add City
  45. $contactmethods['city'] = 'City';
  46. //add State
  47. $contactmethods['state'] = 'State';
  48. //add Postcode
  49. $contactmethods['postcode'] = 'Postcode';
  50. //add Phone
  51. $contactmethods['phone'] = 'Phone';
  52. //add Mobilphone
  53. $contactmethods['mphone'] = 'Mobilphone';
  54.  
  55. return $contactmethods;
  56. }
  57. add_filter('user_contactmethods','my_new_contactmethods',10,1);
  58. add_filter('user_contactmethods','hide_profile_fields',10,1);
  59.  
  60. function my_new_contactmethods( $contactmethods ) {
  61. // Add Twitter
  62. $contactmethods['twitter'] = 'Twitter';
  63. //add Facebook
  64. $contactmethods['facebook'] = 'Facebook';
  65.  
  66. return $contactmethods;
  67. }
  68. add_filter('user_contactmethods','my_new_contactmethods',10,1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement