I'm developing a plugin that uses custom capabilities. Some of those capabilities need to be added to all users who are super admins. Currently, I'm using this code:
$supers = get_super_admins();
foreach ( $supers as $admin ) {
$user = new WP_User( 0, $admin );
$user->add_cap( 'my_cap' );
$user->add_cap( 'my_second_cap' );
}
However, I'm concerned that this code is just adding the capabilities to the individual users, as opposed to the role as I usually would. If a new super admin is created, they will not have these capabilities as this function only runs on plugin activation.
Is there a better way of adding custom capabilities to super admins?