Guest User

Untitled

a guest
Mar 19th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.45 KB | None | 0 0
  1. add_action( 'show_user_profile', 'extra_user_profile_fields' );
  2. add_action( 'edit_user_profile', 'extra_user_profile_fields' );
  3.  
  4. function extra_user_profile_fields( $user ) { ?>
  5. <h3><?php _e("Extra profile information", "blank"); ?></h3>
  6.  
  7. <table class="form-table">
  8. <tr>
  9. <th><label for="phone"><?php _e("Phone"); ?></label></th>
  10. <td>
  11. <input type="text" name="phone" id="phone" value="<?php echo esc_attr( get_the_author_meta( 'phone', $user->ID ) ); ?>" class="regular-text" />
  12. </td>
  13. </tr>
  14. <tr>
  15. <th><label for="address"><?php _e("Address"); ?></label></th>
  16. <td>
  17. <input type="text" name="address" id="address" value="<?php echo esc_attr( get_the_author_meta( 'address', $user->ID ) ); ?>" class="regular-text" />
  18. </td>
  19. </tr>
  20. <tr>
  21. <th><label for="company_name"><?php _e("Company name"); ?></label></th>
  22. <td>
  23. <input type="text" name="company_name" id="company-name" value="<?php echo esc_attr( get_the_author_meta( 'company_name', $user->ID ) ); ?>" class="regular-text" />
  24. </td>
  25. </tr>
  26. <tr>
  27. <th><label for="employees_number"><?php _e("Employees Number"); ?></label></th>
  28. <td>
  29. <input type="number" name="employees_number" id="employees-number" value="<?php echo intval( get_the_author_meta( 'employees_number', $user->ID ) ); ?>" class="regular-text" />
  30. </td>
  31. </tr>
  32. <tr>
  33. <th><label for="foundation_year"><?php _e("Foundation Year"); ?></label></th>
  34. <td>
  35. <input type="number" name="foundation_year" id="foundation-year" value="<?php echo intval( get_the_author_meta( 'foundation_year', $user->ID ) ); ?>" class="regular-text" />
  36. </td>
  37. </tr>
  38. <tr>
  39. <th><label for="mission"><?php _e("Mission"); ?></label></th>
  40. <td>
  41. <textarea name="mission" id="mission" rows="5" cols="30"><?php echo esc_attr( get_the_author_meta( 'mission', $user->ID ) ); ?></textarea>
  42. </td>
  43. </tr>
  44. <tr>
  45. <th><label for="main_activities"><?php _e("Main Activities"); ?></label></th>
  46. <td>
  47. <textarea name="main_activities" id="main-activities" rows="5" cols="30"><?php echo esc_attr( get_the_author_meta( 'main_activities', $user->ID ) ); ?></textarea>
  48. </td>
  49. </tr>
  50. <tr>
  51. <th><label for="where"><?php _e("Will you be working internally in your organization or with external clients?"); ?></label></th>
  52. <td>
  53. <input type="text" name="where" id="where" value="<?php echo esc_attr( get_the_author_meta( 'where', $user->ID ) ); ?>" class="regular-text" />
  54. </td>
  55. </tr>
  56. </table>
  57.  
  58. <?php }
  59.  
  60.  
  61. /*
  62. * Save extra user profile fields
  63. */
  64. add_action( 'personal_options_update', 'save_extra_user_profile_fields' );
  65. add_action( 'edit_user_profile_update', 'save_extra_user_profile_fields' );
  66.  
  67. function save_extra_user_profile_fields( $user_id ) {
  68. if ( !current_user_can( 'edit_user', $user_id ) ) {
  69. return false;
  70. }
  71.  
  72. update_user_meta( $user_id, 'phone', $_POST['phone'] );
  73. update_user_meta( $user_id, 'address', $_POST['address'] );
  74. update_user_meta( $user_id, 'company_name', $_POST['company_name'] );
  75. update_user_meta( $user_id, 'foundation_year', $_POST['foundation_year'] );
  76. update_user_meta( $user_id, 'mission', $_POST['mission'] );
  77. update_user_meta( $user_id, 'main_activities', $_POST['main_activities'] );
  78. update_user_meta( $user_id, 'where', $_POST['where'] );
  79. }
Add Comment
Please, Sign In to add comment