Revert [14011]. Add some actions. fixes #12109, see #12460.

git-svn-id: https://develop.svn.wordpress.org/trunk@14040 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin 2010-04-08 04:15:58 +00:00
parent 8fa7ed4573
commit d07cfaff16
1 changed files with 6 additions and 14 deletions

View File

@ -809,10 +809,7 @@ function _admin_notice_multisite_activate_plugins_page() {
* @param $user_id * @param $user_id
*/ */
function grant_super_admin( $user_id ) { function grant_super_admin( $user_id ) {
global $current_user; do_action( 'grant_super_admin', $user_id );
if ( $current_user->ID == $user_id || !current_user_can( 'manage_network_options' ) )
return;
$super_admins = get_site_option( 'site_admins', array( 'admin' ) ); $super_admins = get_site_option( 'site_admins', array( 'admin' ) );
@ -820,6 +817,7 @@ function grant_super_admin( $user_id ) {
if ( ! in_array( $user->user_login, $super_admins ) ) { if ( ! in_array( $user->user_login, $super_admins ) ) {
$super_admins[] = $user->user_login; $super_admins[] = $user->user_login;
update_site_option( 'site_admins' , $super_admins ); update_site_option( 'site_admins' , $super_admins );
do_action( 'granted_super_admin', $user_id );
} }
} }
@ -830,22 +828,16 @@ function grant_super_admin( $user_id ) {
* @param $user_id * @param $user_id
*/ */
function revoke_super_admin( $user_id ) { function revoke_super_admin( $user_id ) {
global $current_user; do_action( 'revoke_super_admin', $user_id );
if ( $current_user->ID == $user_id || !current_user_can( 'manage_network_options' ) )
return;
$super_admins = get_site_option( 'site_admins', array( 'admin' ) );
if ( count( $super_admins ) < 2 )
return;
$admin_email = get_site_option( 'admin_email' ); $admin_email = get_site_option( 'admin_email' );
$user = new WP_User( $user_id ); $user = new WP_User( $user_id );
if ( $user->ID != $current_user->ID || $user->user_email != $admin_email ) { if ( $user->user_email != $admin_email ) {
foreach ( $super_admins as $key => $username ) { foreach ( $super_admins as $key => $username ) {
if ( $username == $user->user_login ) { if ( $username == $user->user_login ) {
unset( $super_admins[$key] ); unset( $super_admins[$key] );
do_action( 'revoked_super_admin', $user_id );
break; break;
} }
} }