Advertisement
mgunnin

custom-new.php

Dec 9th, 2012
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. <?php
  2.  
  3. // Add extra user settings
  4. function user_interests_fields( $user ) {
  5. if(!current_user_can( 'edit_user', $user->ID ) )
  6. return false;
  7. $is_gamer = get_the_author_meta( 'is_gamer', $user->ID ); ?>
  8. <h3><?php _e('Extra Settings', 'dp'); ?></h3>
  9. <table class="form-table">
  10. <tr>
  11. <th><?php _e('Is gamer?', 'dp'); ?></th>
  12. <td>
  13. <label for="user_interests_<?php echo esc_attr( $tag->slug); ?>">
  14. <input id="is_gamer" name="is_gamer" type="checkbox" value="1" <?php if($is_gamer) echo ' checked="checked"'; ?> />
  15. <?php _e('Check this if this user is a gamer.', 'dp'); ?>
  16. </label>
  17. </td>
  18. </tr>
  19. </table>
  20. $is_team = get_the_author_meta( 'is_team', $team->ID ); ?>
  21. <table class="form-table">
  22. <tr>
  23. <th><?php _e('Is team?', 'dp'); ?></th>
  24. <td>
  25. <label for="user_interests_<?php echo esc_attr( $tag->slug); ?>">
  26. <input id="is_team" name="is_team" type="checkbox" value="1" <?php if($is_team) echo ' checked="checked"'; ?> />
  27. <?php _e('Check this if this user is a team.', 'dp'); ?>
  28. </label>
  29. </td>
  30. </tr>
  31. </table>
  32. <?php }
  33. add_action( 'show_user_profile', 'user_interests_fields' );
  34. add_action( 'edit_user_profile', 'user_interests_fields' );
  35.  
  36. // Store extra user settings
  37. function user_interests_fields_save( $user_id ) {
  38. if(!current_user_can( 'edit_user', $user_id ) )
  39. return false;
  40.  
  41. update_user_meta( $user_id, 'is_gamer', $_POST['is_gamer'] );
  42. update_user_meta( $user_id, 'is_team', $_POST['is_team'] );
  43. }
  44. add_action( 'personal_options_update', 'user_interests_fields_save' );
  45. add_action( 'edit_user_profile_update', 'user_interests_fields_save' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement