Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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("Extra profile information", "blank"); ?></h3>
- <table class="form-table">
- <tr>
- <th><label for="phone"><?php _e("Phone"); ?></label></th>
- <td>
- <input type="text" name="phone" id="phone" value="<?php echo esc_attr( get_the_author_meta( 'phone', $user->ID ) ); ?>" class="regular-text" />
- </td>
- </tr>
- <tr>
- <th><label for="address"><?php _e("Address"); ?></label></th>
- <td>
- <input type="text" name="address" id="address" value="<?php echo esc_attr( get_the_author_meta( 'address', $user->ID ) ); ?>" class="regular-text" />
- </td>
- </tr>
- <tr>
- <th><label for="company_name"><?php _e("Company name"); ?></label></th>
- <td>
- <input type="text" name="company_name" id="company-name" value="<?php echo esc_attr( get_the_author_meta( 'company_name', $user->ID ) ); ?>" class="regular-text" />
- </td>
- </tr>
- <tr>
- <th><label for="employees_number"><?php _e("Employees Number"); ?></label></th>
- <td>
- <input type="number" name="employees_number" id="employees-number" value="<?php echo intval( get_the_author_meta( 'employees_number', $user->ID ) ); ?>" class="regular-text" />
- </td>
- </tr>
- <tr>
- <th><label for="foundation_year"><?php _e("Foundation Year"); ?></label></th>
- <td>
- <input type="number" name="foundation_year" id="foundation-year" value="<?php echo intval( get_the_author_meta( 'foundation_year', $user->ID ) ); ?>" class="regular-text" />
- </td>
- </tr>
- <tr>
- <th><label for="mission"><?php _e("Mission"); ?></label></th>
- <td>
- <textarea name="mission" id="mission" rows="5" cols="30"><?php echo esc_attr( get_the_author_meta( 'mission', $user->ID ) ); ?></textarea>
- </td>
- </tr>
- <tr>
- <th><label for="main_activities"><?php _e("Main Activities"); ?></label></th>
- <td>
- <textarea name="main_activities" id="main-activities" rows="5" cols="30"><?php echo esc_attr( get_the_author_meta( 'main_activities', $user->ID ) ); ?></textarea>
- </td>
- </tr>
- <tr>
- <th><label for="where"><?php _e("Will you be working internally in your organization or with external clients?"); ?></label></th>
- <td>
- <input type="text" name="where" id="where" value="<?php echo esc_attr( get_the_author_meta( 'where', $user->ID ) ); ?>" class="regular-text" />
- </td>
- </tr>
- </table>
- <?php }
- /*
- * Save extra user profile fields
- */
- 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;
- }
- update_user_meta( $user_id, 'phone', $_POST['phone'] );
- update_user_meta( $user_id, 'address', $_POST['address'] );
- update_user_meta( $user_id, 'company_name', $_POST['company_name'] );
- update_user_meta( $user_id, 'foundation_year', $_POST['foundation_year'] );
- update_user_meta( $user_id, 'mission', $_POST['mission'] );
- update_user_meta( $user_id, 'main_activities', $_POST['main_activities'] );
- update_user_meta( $user_id, 'where', $_POST['where'] );
- }
Add Comment
Please, Sign In to add comment