mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
Move add/remove super admin out of bulk edit and into user-edit.php. Introduce grant_super_admin() and revoke_super_admin(). Link to profile.php in ms-users user row for current user. Add defensive check by forcing IS_PROFILE_PAGE on user-edit if trying to edit your own user_id. see #12460
git-svn-id: https://develop.svn.wordpress.org/trunk@13941 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -793,4 +793,42 @@ function _admin_notice_multisite_activate_plugins_page() {
|
||||
echo "<div class='error'><p>$message</p></div>";
|
||||
}
|
||||
|
||||
/**
|
||||
* Grants super admin privileges.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param $user_id
|
||||
*/
|
||||
function grant_super_admin( $user_id ) {
|
||||
$super_admins = get_site_option( 'site_admins', array( 'admin' ) );
|
||||
|
||||
$user = new WP_User( $user_id );
|
||||
if ( ! in_array( $user->user_login, $super_admins ) ) {
|
||||
$super_admins[] = $user->user_login;
|
||||
update_site_option( 'site_admins' , $super_admins );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Revokes super admin privileges.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param $user_id
|
||||
*/
|
||||
function revoke_super_admin( $user_id ) {
|
||||
$super_admins = get_site_option( 'site_admins', array( 'admin' ) );
|
||||
$admin_email = get_site_option( 'admin_email' );
|
||||
|
||||
$user = new WP_User( $user_id );
|
||||
if ( $user->ID != $current_user->ID || $user->user_email != $admin_email ) {
|
||||
foreach ( $super_admins as $key => $username ) {
|
||||
if ( $username == $user->user_login ) {
|
||||
unset( $super_admins[$key] );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
update_site_option( 'site_admins' , $super_admins );
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user