Advertisement
Guest User

CAMPOS EXTRA AUTORES WP

a guest
Mar 4th, 2012
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. // CAMPOS TWITTER, FACEBOOK,SITIO PERSONAL AUTORES
  2. add_action( 'show_user_profile', 'extra_user_profile_fields' );
  3. add_action( 'edit_user_profile', 'extra_user_profile_fields' );
  4. function extra_user_profile_fields( $user ) { ?>
  5. <h3><?php _e("Campos adicionales", "blank"); ?></h3>
  6. <table class="form-table">
  7. <tr>
  8. <th><label for="url-facebook"><?php _e("Facebook"); ?></label></th>
  9. <td>
  10. <input type="text" name="url-facebook" id="url-facebook"
  11. value="<?php echo esc_attr( get_the_author_meta( 'url-facebook', $user->ID ) ); ?>"
  12. class="regular-text" /><br />
  13. <span class="description">
  14. <?php _e("Inserta tu direccion de Facebook"); ?></span>
  15. </td>
  16. </tr>
  17. </table>
  18. <table class="form-table">
  19. <tr>
  20. <th><label for="url-twitter"><?php _e("Twitter"); ?></label></th>
  21. <td>
  22. <input type="text" name="url-twitter" id="url-twitter"
  23. value="<?php echo esc_attr( get_the_author_meta( 'url-twitter', $user->ID ) ); ?>"
  24. class="regular-text" /><br />
  25. <span class="description">
  26. <?php _e("Inserta tu direccion o nombre de cuenta de Twitter"); ?></span>
  27. </td>
  28. </tr>
  29. </table>
  30. <table class="form-table">
  31. <tr>
  32. <th><label for="url-flickr"><?php _e("Flickr"); ?></label></th>
  33. <td>
  34. <input type="text" name="url-flickr" id="url-flickr"
  35. value="<?php echo esc_attr( get_the_author_meta( 'url-flickr', $user->ID ) ); ?>"
  36. class="regular-text" /><br />
  37. <span class="description">
  38. <?php _e("Inserta tu direccion de Flickr"); ?></span>
  39. </td>
  40. </tr>
  41. </table>
  42. <?php }
  43. //Este bloque actualiza el campo al guardar los cambios
  44. add_action( 'personal_options_update', 'save_extra_user_profile_fields' );
  45. add_action( 'edit_user_profile_update', 'save_extra_user_profile_fields' );
  46. function save_extra_user_profile_fields( $user_id ) {
  47. if ( !current_user_can( 'edit_user', $user_id ) ) { return false; }
  48. // Actualizamos cada campo adicional con su ID
  49. update_usermeta( $user_id, 'url-facebook', $_POST['url-facebook'] );
  50. update_usermeta( $user_id, 'url-twitter', $_POST['url-twitter'] );
  51. update_usermeta( $user_id, 'url-flickr', $_POST['url-flickr'] );
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement