Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Add additional custom fields to profile page
- */
- add_action ( 'show_user_profile', 'wpq_show_extra_profile_fields' );
- add_action ( 'edit_user_profile', 'wpq_show_extra_profile_fields' );
- function wpq_show_extra_profile_fields ( $user ) {
- ?>
- <h3><?php _e( 'Extra Profile Info'); ?></h3>
- <table class="form-table">
- <?php // duplicate this chunk (changing the meta field) for more fields ?>
- <tr>
- <th><label for="icl_admin_language"><?php _e( 'Admin Language' ); ?></label></th>
- <td>
- <?php $value = get_the_author_meta( 'icl_admin_language', $user->ID ); ?>
- <select name="icl_admin_language" id="icl_admin_language">
- <option value="en" <?php selected( $value, 'en' ); ?>>English</option>
- <option value="es" <?php selected( $value, 'es' ); ?>>Espanol</option>
- <option value="it" <?php selected( $value, 'it' ); ?>>Italiano</option>
- </select>
- </td>
- </tr>
- <?php // end of chunk ?>
- </table>
- <?php
- }
- /**
- * Save data input from custom field on profile page
- */
- add_action ( 'personal_options_update', 'wpq_save_extra_profile_fields' );
- add_action ( 'edit_user_profile_update', 'wpq_save_extra_profile_fields' );
- function wpq_save_extra_profile_fields( $user_id ) {
- if ( !current_user_can( 'edit_user', $user_id ) )
- return false;
- // copy this line for other fields
- update_user_meta( $user_id, 'icl_admin_language', $_POST['icl_admin_language'] );
- }
Advertisement
Add Comment
Please, Sign In to add comment