I see a lot of threads about this, explaining how to edit the database records to fix this, but that didn’t work for me
instead I just put this in a plugin and later removed it (4 is user id I want to make super admin)
grant_super_admin(4);
that alone caused some errors, I had to add other code to make it work, which still caused a different error but it had the desired effect and I could just delete all this when I was done (I’m just wondering if this is a symptom of other problems with my installation)
require_once(ABSPATH . 'wp-includes/pluggable.php');
grant_super_admin(4);
function grant_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( 'grant_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 ( ! in_array( $user->user_login, $super_admins ) ) {
$super_admins[] = $user->user_login;
update_site_option( 'site_admins' , $super_admins );
do_action( 'granted_super_admin', $user_id );
return true;
}
return false;
}