Advertisement
thesufi

wp profile extra field

May 8th, 2013
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.84 KB | None | 0 0
  1. add_action( 'edit_user_profile', 'show_extra_profile_fields', 10 );
  2.  
  3. function show_extra_profile_fields( $user ) { ?>
  4.     <table class="form-table">
  5.         <tr>
  6.             <th><label for="roll"><?php _e('Roll No.', 'frontendprofile'); ?></label></th>
  7.             <td>
  8.                 <input type="text" name="roll" id="roll" value="<?php echo esc_attr( get_the_author_meta( 'roll', $user->ID ) ); ?>" class="regular-text" /><br />
  9.                 <span class="description"><?php _e('Please enter Roll No.', 'frontendprofile'); ?></span>
  10.             </td>
  11.         </tr>
  12.     </table>
  13. <?php }
  14.  
  15. add_action( 'personal_options_update', 'save_extra_profile_fields' );
  16. add_action( 'edit_user_profile_update', 'save_extra_profile_fields' );
  17.  
  18. function save_extra_profile_fields( $user_id ) {
  19.     if ( !current_user_can( 'edit_user', $user_id ) )
  20.         return false;
  21.     update_usermeta( $user_id, 'roll', $_POST['roll'] );
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement