I cannot test this, since I am not getting your problem when I add the code, but try these changes below. I have made the code to work only if the page is not in the network admin. Please test it as a super admin and as other users to verify that it works well.
function restrict_roles_get_allowed_roles( $user ) {
$allowed = array();
if ( in_array( 'administrator', $user->roles ) ) { // Admin can edit all roles
$allowed = array_keys( $GLOBALS['wp_roles']->roles );
} elseif ( in_array( 'basic', $user->roles ) ) { // If role is "Basic"
$allowed[] = 'user'; // Allow only role User
/* $allowed[] = 'additionalrole'; */ // Allow only role additionalrole
} elseif ( in_array( 'standard', $user->roles ) ) { // If role is "Standard"
$allowed[] = 'user'; // Allow only role User
} elseif ( in_array( 'premium', $user->roles ) ) { // If role is "Premium"
$allowed[] = 'user'; // Allow only role User
}
return $allowed;
}
/* Remove roles that are not allowed for the current user role. */
function restrict_roles_editable_roles( $roles ) {
if ( $user = wp_get_current_user() ) {
$allowed = restrict_roles_get_allowed_roles( $user );
foreach ( $roles as $role => $caps ) {
if ( ! in_array( $role, $allowed ) )
unset( $roles[ $role ] );
}
}
return $roles;
}
/* Prevent users deleting/editing users with a role outside their allowance. */
function restrict_roles_map_meta_cap( $caps, $cap, $user_ID, $args ) {
if ( ( $cap === 'edit_user' || $cap === 'delete_user' ) && $args ) {
$the_user = get_userdata( $user_ID ); // The user performing the task
$user = get_userdata( $args[0] ); // The user being edited/deleted
if ( $the_user && $user && $the_user->ID != $user->ID /* User can always edit self */ ) {
$allowed = restrict_roles_get_allowed_roles( $the_user );
if ( array_diff( $user->roles, $allowed ) ) {
// Target user has roles outside of our limits
$caps[] = 'not_allowed';
}
}
}
return $caps;
}
if ( ! function_exists( 'unregister_post_type' ) ) :
function unregister_post_type() {
global $wp_post_types;
if ( isset( $wp_post_types[ 'post' ] ) ) {
unset( $wp_post_types[ 'post' ] );
return true;
}
return false;
}
endif;
if ( ! is_network_admin() ) {
add_action('init', 'unregister_post_type',100);
add_filter( 'map_meta_cap', 'restrict_roles_map_meta_cap', 10, 4 );
add_filter( 'editable_roles', 'restrict_roles_editable_roles' );
}