psudo admin custom user role cant access member pages

Hi,

I am using membership 2 pro and created a few pages for members. I also have a user custom admin user role called Sub Admin defined as follows:

$admin = get_role('administrator');
add_role(
'sub_admin',
'Sub Administrator',
$admin->capabilities
);
$wp_roles->remove_cap( 'sub_admin', 'activate_plugins');
$wp_roles->remove_cap( 'sub_admin', 'install_plugins');
$wp_roles->remove_cap( 'sub_admin', 'update_plugins');
$wp_roles->remove_cap( 'sub_admin', 'edit_plugins');
$wp_roles->remove_cap( 'sub_admin', 'delete_plugins');
$wp_roles->remove_cap( 'sub_admin', 'switch_themes');
$wp_roles->remove_cap( 'sub_admin', 'edit_themes');
$wp_roles->remove_cap( 'sub_admin', 'install_themes');
$wp_roles->remove_cap( 'sub_admin', 'update_themes');
}

When I go to Membership->members this user shows up as admin so I cant assign him any permissions but when the user logs in, he cant access the member pages.

I have several standard user roles, and they all allow me to set permissions for the user without any problem. Its just this “sub admin” role that is having issues.

Please help me fix this issue.