if ( IS_PROFILE_PAGE ) { // Used in the HTML title tag. $title = __( 'Profile' ); } else { // Used in the HTML title tag. /* translators: %s: User's display name. */ $title = __( 'Edit User %s' ); }
$profile_help = '<p>' . __( 'Your profile contains information about you (your “account”) as well as some personal options related to using WordPress.' ) . '</p>' . '<p>' . __( 'You can change your password, turn on keyboard shortcuts, change the color scheme of your WordPress administration screens, and turn off the WYSIWYG (Visual) editor, among other things. You can hide the Toolbar (formerly called the Admin Bar) from the front end of your site, however it cannot be disabled on the admin screens.' ) . '</p>' . '<p>' . __( 'You can select the language you wish to use while using the WordPress administration screen without affecting the language site visitors see.' ) . '</p>' . '<p>' . __( 'Your username cannot be changed, but you can use other fields to enter your real name or a nickname, and change which name to display on your posts.' ) . '</p>' . '<p>' . __( 'You can log out of other devices, such as your phone or a public computer, by clicking the Log Out Everywhere Else button.' ) . '</p>' . '<p>' . __( 'Required fields are indicated; the rest are optional. Profile information will only be displayed if your theme is set up to do so.' ) . '</p>' . '<p>' . __( 'Remember to click the Update Profile button when you are finished.' ) . '</p>';
/** * Filters whether to allow administrators on Multisite to edit every user. * * Enabling the user editing form via this filter also hinges on the user holding * the 'manage_network_users' cap, and the logged-in user not matching the user * profile open for editing. * * The filter was introduced to replace the EDIT_ANY_USER constant. * * @since 3.0.0 * * @param bool $allow Whether to allow editing of any user. Default true. */ if ( is_multisite() && ! current_user_can( 'manage_network_users' ) && $user_id !== $current_user->ID && ! apply_filters( 'enable_edit_any_user_configuration', true ) ) { wp_die( __( 'Sorry, you are not allowed to edit this user.' ) ); }
if ( ! current_user_can( 'edit_user', $user_id ) ) { wp_die( __( 'Sorry, you are not allowed to edit this user.' ) ); }
if ( IS_PROFILE_PAGE ) { /** * Fires before the page loads on the 'Profile' editing screen. * * The action only fires if the current user is editing their own profile. * * @since 2.0.0 * * @param int $user_id The user ID. */ do_action( 'personal_options_update', $user_id ); } else { /** * Fires before the page loads on the 'Edit User' screen. * * @since 2.7.0 * * @param int $user_id The user ID. */ do_action( 'edit_user_profile_update', $user_id ); }
// Update the email address in signups, if present. if ( is_multisite() ) { $user = get_userdata( $user_id );
if ( $user->user_login && isset( $_POST['email'] ) && is_email( $_POST['email'] ) && $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $user->user_login ) ) ) { $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $_POST['email'], $user_login ) ); } }
// Update the user. $errors = edit_user( $user_id );
// Grant or revoke super admin status if requested. if ( is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && ! isset( $super_admins ) && empty( $_POST['super_admin'] ) === is_super_admin( $user_id ) ) { empty( $_POST['super_admin'] ) ? revoke_super_admin( $user_id ) : grant_super_admin( $user_id ); }
<?php if ( count( $_wp_admin_css_colors ) > 1 && has_action( 'admin_color_scheme_picker' ) ) : ?> <tr class="user-admin-color-wrap"> <th scope="row"><?php _e( 'Admin Color Scheme' ); ?></th> <td> <?php /** * Fires in the 'Admin Color Scheme' section of the user editing screen. * * The section is only enabled if a callback is hooked to the action, * and if there is more than one defined color scheme for the admin. * * @since 3.0.0 * @since 3.8.1 Added `$user_id` parameter. * * @param int $user_id The user ID. */ do_action( 'admin_color_scheme_picker', $user_id ); ?> </td> </tr> <?php endif; // End if count ( $_wp_admin_css_colors ) > 1 ?>
<?php /** * Fires at the end of the 'Personal Options' settings table on the user editing screen. * * @since 2.7.0 * * @param WP_User $profile_user The current WP_User object. */ do_action( 'personal_options', $profile_user ); ?>
</table> <?php if ( IS_PROFILE_PAGE ) { /** * Fires after the 'Personal Options' settings table on the 'Profile' editing screen. * * The action only fires if the current user is editing their own profile. * * @since 2.0.0 * * @param WP_User $profile_user The current WP_User object. */ do_action( 'profile_personal_options', $profile_user ); } ?>
// Print the full list of roles with the primary one selected. wp_dropdown_roles( $user_role );
// Print the 'no role' option. Make it selected if the user has no role yet. if ( $user_role ) { echo '<option value="">' . __( '— No role for this site —' ) . '</option>'; } else { echo '<option value="" selected="selected">' . __( '— No role for this site —' ) . '</option>'; } ?> </select> </td> </tr> <?php endif; // End if ! IS_PROFILE_PAGE. ?>
<?php if ( is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && ! isset( $super_admins ) ) : ?> <tr class="user-super-admin-wrap"> <th><?php _e( 'Super Admin' ); ?></th> <td> <?php if ( 0 !== strcasecmp( $profile_user->user_email, get_site_option( 'admin_email' ) ) || ! is_super_admin( $profile_user->ID ) ) : ?> <p><label><input type="checkbox" id="super_admin" name="super_admin"<?php checked( is_super_admin( $profile_user->ID ) ); ?> /> <?php _e( 'Grant this user super admin privileges for the Network.' ); ?></label></p> <?php else : ?> <p><?php _e( 'Super admin privileges cannot be removed because this user has the network admin email.' ); ?></p> <?php endif; ?> </td> </tr> <?php endif; ?>
<table class="form-table" role="presentation"> <tr class="user-description-wrap"> <th><label for="description"><?php _e( 'Biographical Info' ); ?></label></th> <td><textarea name="description" id="description" rows="5" cols="30"><?php echo $profile_user->description; // textarea_escaped ?></textarea> <p class="description"><?php _e( 'Share a little biographical information to fill out your profile. This may be shown publicly.' ); ?></p></td> </tr>
/** * Filters the user profile picture description displayed under the Gravatar. * * @since 4.4.0 * @since 4.7.0 Added the `$profile_user` parameter. * * @param string $description The description that will be printed. * @param WP_User $profile_user The current WP_User object. */ echo apply_filters( 'user_profile_picture_description', $description, $profile_user ); ?> </p> </td> </tr> <?php endif; ?> <?php /** * Filters the display of the password fields. * * @since 1.5.1 * @since 2.8.0 Added the `$profile_user` parameter. * @since 4.4.0 Now evaluated only in user-edit.php. * * @param bool $show Whether to show the password fields. Default true. * @param WP_User $profile_user User object for the current user to edit. */ $show_password_fields = apply_filters( 'show_password_fields', true, $profile_user ); ?> <?php if ( $show_password_fields ) : ?> </table>
<?php // Allow admins to send reset password link. ?> <?php if ( ! IS_PROFILE_PAGE && true === wp_is_password_reset_allowed_for_user( $profile_user ) ) : ?> <tr class="user-generate-reset-link-wrap hide-if-no-js"> <th><?php _e( 'Password Reset' ); ?></th> <td> <div class="generate-reset-link"> <button type="button" class="button button-secondary" id="generate-reset-link"> <?php _e( 'Send Reset Link' ); ?> </button> </div> <p class="description"> <?php printf( /* translators: %s: User's display name. */ __( 'Send %s a link to reset their password. This will not change their password, nor will it force a change.' ), esc_html( $profile_user->display_name ) ); ?> </p> </td> </tr> <?php endif; ?>
<?php if ( IS_PROFILE_PAGE && count( $sessions->get_all() ) === 1 ) : ?> <tr class="user-sessions-wrap hide-if-no-js"> <th><?php _e( 'Sessions' ); ?></th> <td aria-live="assertive"> <div class="destroy-sessions"><button type="button" disabled class="button"><?php _e( 'Log Out Everywhere Else' ); ?></button></div> <p class="description"> <?php _e( 'You are only logged in at this location.' ); ?> </p> </td> </tr> <?php elseif ( IS_PROFILE_PAGE && count( $sessions->get_all() ) > 1 ) : ?> <tr class="user-sessions-wrap hide-if-no-js"> <th><?php _e( 'Sessions' ); ?></th> <td aria-live="assertive"> <div class="destroy-sessions"><button type="button" class="button" id="destroy-sessions"><?php _e( 'Log Out Everywhere Else' ); ?></button></div> <p class="description"> <?php _e( 'Did you lose your phone or leave your account logged in at a public computer? You can log out everywhere else, and stay logged in here.' ); ?> </p> </td> </tr> <?php elseif ( ! IS_PROFILE_PAGE && $sessions->get_all() ) : ?> <tr class="user-sessions-wrap hide-if-no-js"> <th><?php _e( 'Sessions' ); ?></th> <td> <p><button type="button" class="button" id="destroy-sessions"><?php _e( 'Log Out Everywhere' ); ?></button></p> <p class="description"> <?php /* translators: %s: User's display name. */ printf( __( 'Log %s out of all locations.' ), $profile_user->display_name ); ?> </p> </td> </tr> <?php endif; ?> </table>
<?php if ( wp_is_application_passwords_available_for_user( $user_id ) || ! wp_is_application_passwords_supported() ) : ?> <div class="application-passwords hide-if-no-js" id="application-passwords-section"> <h2><?php _e( 'Application Passwords' ); ?></h2> <p><?php _e( 'Application passwords allow authentication via non-interactive systems, such as XML-RPC or the REST API, without providing your actual password. Application passwords can be easily revoked. They cannot be used for traditional logins to your website.' ); ?></p> <?php if ( wp_is_application_passwords_available_for_user( $user_id ) ) : ?> <?php if ( is_multisite() ) : $blogs = get_blogs_of_user( $user_id, true ); $blogs_count = count( $blogs );
if ( $blogs_count > 1 ) : ?> <p> <?php /* translators: 1: URL to my-sites.php, 2: Number of sites the user has. */ $message = _n( 'Application passwords grant access to <a href="%1$s">the %2$s site in this installation that you have permissions on</a>.', 'Application passwords grant access to <a href="%1$s">all %2$s sites in this installation that you have permissions on</a>.', $blogs_count );
if ( is_super_admin( $user_id ) ) { /* translators: 1: URL to my-sites.php, 2: Number of sites the user has. */ $message = _n( 'Application passwords grant access to <a href="%1$s">the %2$s site on the network as you have Super Admin rights</a>.', 'Application passwords grant access to <a href="%1$s">all %2$s sites on the network as you have Super Admin rights</a>.', $blogs_count ); }
<?php if ( ! wp_is_site_protected_by_basic_auth( 'front' ) ) : ?> <div class="create-application-password form-wrap"> <div class="form-field"> <label for="new_application_password_name"><?php _e( 'New Application Password Name' ); ?></label> <input type="text" size="30" id="new_application_password_name" name="new_application_password_name" class="input" aria-required="true" aria-describedby="new_application_password_name_desc" spellcheck="false" /> <p class="description" id="new_application_password_name_desc"><?php _e( 'Required to create an Application Password, but not to update the user.' ); ?></p> </div>
<?php /** * Fires in the create Application Passwords form. * * @since 5.6.0 * * @param WP_User $profile_user The current WP_User object. */ do_action( 'wp_create_application_password_form', $profile_user ); ?>
<button type="button" name="do_new_application_password" id="do_new_application_password" class="button button-secondary"><?php _e( 'Add Application Password' ); ?></button> </div> <?php else : wp_admin_notice( __( 'Your website appears to use Basic Authentication, which is not currently compatible with Application Passwords.' ), array( 'type' => 'error', 'additional_classes' => array( 'inline' ), ) ); endif; ?>
<div class="application-passwords-list-table-wrapper"> <?php $application_passwords_list_table = _get_list_table( 'WP_Application_Passwords_List_Table', array( 'screen' => 'application-passwords-user' ) ); $application_passwords_list_table->prepare_items(); $application_passwords_list_table->display(); ?> </div> <?php elseif ( ! wp_is_application_passwords_supported() ) : ?> <p><?php _e( 'The application password feature requires HTTPS, which is not enabled on this site.' ); ?></p> <p> <?php printf( /* translators: %s: Documentation URL. */ __( 'If this is a development website, you can <a href="%s">set the environment type accordingly</a> to enable application passwords.' ), __( 'https://developer.wordpress.org/apis/wp-config-php/#wp-environment-type' ) ); ?> </p> <?php endif; ?> </div> <?php endif; // End Application Passwords. ?>
<?php if ( IS_PROFILE_PAGE ) { /** * Fires after the 'About Yourself' settings table on the 'Profile' editing screen. * * The action only fires if the current user is editing their own profile. * * @since 2.0.0 * * @param WP_User $profile_user The current WP_User object. */ do_action( 'show_user_profile', $profile_user ); } else { /** * Fires after the 'About the User' settings table on the 'Edit User' screen. * * @since 2.0.0 * * @param WP_User $profile_user The current WP_User object. */ do_action( 'edit_user_profile', $profile_user ); } ?>
<?php /** * Filters whether to display additional capabilities for the user. * * The 'Additional Capabilities' section will only be enabled if * the number of the user's capabilities exceeds their number of * roles. * * @since 2.8.0 * * @param bool $enable Whether to display the capabilities. Default true. * @param WP_User $profile_user The current WP_User object. */ $display_additional_caps = apply_filters( 'additional_capabilities_display', true, $profile_user ); ?>