Advertisements

revoke_super_admin

Definition:
function revoke_super_admin( $user_id ) {}

Revokes super admin privileges.

Parameters

  • int $user_id

Defined actions

  • revoke_super_admin
    do_action( 'revoke_super_admin', $user_id );
  • revoked_super_admin
    do_action( 'revoked_super_admin', $user_id );

Source code

function revoke_super_admin( $user_id ) {

	global $super_admins;



	// If global super_admins override is defined, there is nothing to do here.

	if ( isset($super_admins) )

		return false;



	do_action( 'revoke_super_admin', $user_id );



	// Directly fetch site_admins instead of using get_super_admins()

	$super_admins = get_site_option( 'site_admins', array( 'admin' ) );



	$user = new WP_User( $user_id );

	if ( $user->user_email != get_site_option( 'admin_email' ) ) {

		if ( false !== ( $key = array_search( $user->user_login, $super_admins ) ) ) {

			unset( $super_admins[$key] );

			update_site_option( 'site_admins', $super_admins );

			do_action( 'revoked_super_admin', $user_id );

			return true;

		}

	}

	return false;

}

2747

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: