Advertisement
produitsmama

Help: How-to Read-Only Field

Jun 19th, 2012
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. <?php
  2.  
  3. add_action( 'show_user_profile', 'my_show_extra_profile_fields' );
  4. add_action( 'edit_user_profile', 'my_show_extra_profile_fields' );
  5.  
  6. function my_show_extra_profile_fields( $user ) { ?>
  7.  
  8. <h3>Code Rep Unique</h3>
  9.  
  10. <table class="form-table">
  11.  
  12. <tr>
  13. <th><label for="jobpos">Votre Code Rep Unique</label></th>
  14.  
  15. <td>
  16. <input type="text" name="jobpos" id="jobpos" value="<?php echo esc_attr( get_the_author_meta( 'jobpos', $user->ID ) ); ?>" class="regular-text" /><br />
  17. <span class="description">Ce code est confidentiel et unique pour chacun des reps.</span>
  18. </td>
  19. </tr>
  20.  
  21. </table>
  22. <?php }
  23.  
  24. add_action( 'personal_options_update', 'my_save_extra_profile_fields' );
  25. add_action( 'edit_user_profile_update', 'my_save_extra_profile_fields' );
  26.  
  27. function my_save_extra_profile_fields( $user_id ) {
  28.  
  29. if ( !current_user_can( 'edit_user', $user_id ) )
  30. return false;
  31.  
  32. update_usermeta( $user_id, 'jobpos', $_POST['jobpos'] );
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement