Guest User

Untitled

a guest
Apr 19th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. add_action('show_user_profile', 'addCityField');
  2. add_action('personal_options_update','updateCityField');
  3.  
  4. // show input field for city information on the user's profile page
  5. function addCityField() {
  6. global $user_ID;
  7. $legend = 'Location';
  8. $group = 'field_group';
  9.  
  10. $prefix_html = " <fieldset><legend>$legend</legend>";
  11. $postfix_html = '</fieldset>';
  12. $body_html = '';
  13.  
  14. $body_html .="<p><label>City</label><br />";
  15. $body_html .= "<input type='text' name='city' value='" . get_usermeta($user_ID,'city') . "' />";
  16. $body_html .= "</p>\n";
  17.  
  18. echo $prefix_html.$body_html.$postfix_html;
  19.  
  20. }
  21. // if user makes changes to city field on his profile page, save the changes
  22. function updateCityField() {
  23. global $user_ID;
  24. $city = $_POST["city"];
  25. update_usermeta($user_ID,"city", $city);
  26.  
  27. }
Add Comment
Please, Sign In to add comment