Advertisement
Guest User

Untitled

a guest
Aug 9th, 2012
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. ///////// this goes in your theme's functions.php
  2.  
  3. function my_enqueue($hook) {
  4. if( 'profile.php' != $hook )
  5. return;
  6. wp_register_script( 'my_profile_script',get_template_directory_uri() . '/js/my_profile_script.js',
  7. array('jquery') );
  8. wp_enqueue_script( 'my_profile_script');
  9. }
  10. add_action( 'admin_enqueue_scripts', 'my_enqueue' );
  11.  
  12.  
  13.  
  14.  
  15. add_action( 'show_user_profile', 'extra_user_profile_fields' );
  16. add_action( 'edit_user_profile', 'extra_user_profile_fields' );
  17.  
  18. function extra_user_profile_fields( $user ) {
  19. ?>
  20. <h3><?php _e("Extra profile information", "blank"); ?></h3>
  21.  
  22. <table class="form-table" id="mytable">
  23. <tr>
  24. <th><label for="title"><?php _e("title"); ?></label></th>
  25. <td>
  26. <input type="text" name="title" id="title" value="<?php echo esc_attr( get_the_author_meta( 'title', $user->ID ) ); ?>" class="regular-text" /><br />
  27. <span class="description"><?php _e("Please enter your title."); ?></span>
  28. </td>
  29. </tr>
  30. </table>
  31. <?php }
  32.  
  33. add_action( 'personal_options_update', 'save_extra_user_profile_fields' );
  34. add_action( 'edit_user_profile_update', 'save_extra_user_profile_fields' );
  35.  
  36. function save_extra_user_profile_fields( $user_id ) {
  37.  
  38. if ( !current_user_can( 'edit_user', $user_id ) ) { return false; }
  39.  
  40. update_user_meta( $user_id, 'title', $_POST['title'] );
  41.  
  42. }
  43.  
  44.  
  45. //////////// this goes in a file called my_profile_script.js /////////
  46.  
  47. (function($) {
  48. $(document).ready( function() {
  49. var title = $('#mytable tr:eq(0)');
  50. $('#mytable').remove();
  51. $("#user_login").closest('tr').after(title);
  52. });
  53. })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement