Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // CAMPOS TWITTER, FACEBOOK,SITIO PERSONAL AUTORES
- add_action( 'show_user_profile', 'extra_user_profile_fields' );
- add_action( 'edit_user_profile', 'extra_user_profile_fields' );
- function extra_user_profile_fields( $user ) { ?>
- <h3><?php _e("Campos adicionales", "blank"); ?></h3>
- <table class="form-table">
- <tr>
- <th><label for="url-facebook"><?php _e("Facebook"); ?></label></th>
- <td>
- <input type="text" name="url-facebook" id="url-facebook"
- value="<?php echo esc_attr( get_the_author_meta( 'url-facebook', $user->ID ) ); ?>"
- class="regular-text" /><br />
- <span class="description">
- <?php _e("Inserta tu direccion de Facebook"); ?></span>
- </td>
- </tr>
- </table>
- <table class="form-table">
- <tr>
- <th><label for="url-twitter"><?php _e("Twitter"); ?></label></th>
- <td>
- <input type="text" name="url-twitter" id="url-twitter"
- value="<?php echo esc_attr( get_the_author_meta( 'url-twitter', $user->ID ) ); ?>"
- class="regular-text" /><br />
- <span class="description">
- <?php _e("Inserta tu direccion o nombre de cuenta de Twitter"); ?></span>
- </td>
- </tr>
- </table>
- <table class="form-table">
- <tr>
- <th><label for="url-flickr"><?php _e("Flickr"); ?></label></th>
- <td>
- <input type="text" name="url-flickr" id="url-flickr"
- value="<?php echo esc_attr( get_the_author_meta( 'url-flickr', $user->ID ) ); ?>"
- class="regular-text" /><br />
- <span class="description">
- <?php _e("Inserta tu direccion de Flickr"); ?></span>
- </td>
- </tr>
- </table>
- <?php }
- //Este bloque actualiza el campo al guardar los cambios
- add_action( 'personal_options_update', 'save_extra_user_profile_fields' );
- add_action( 'edit_user_profile_update', 'save_extra_user_profile_fields' );
- function save_extra_user_profile_fields( $user_id ) {
- if ( !current_user_can( 'edit_user', $user_id ) ) { return false; }
- // Actualizamos cada campo adicional con su ID
- update_usermeta( $user_id, 'url-facebook', $_POST['url-facebook'] );
- update_usermeta( $user_id, 'url-twitter', $_POST['url-twitter'] );
- update_usermeta( $user_id, 'url-flickr', $_POST['url-flickr'] );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement