How do I limit information being applied only to Network Administrators?
TL;DR; I am building a multisite for a City Council where every member will have its own subdomain. In one of the plugins, I want to limit some menu options to be shown only to the users with the network admin role.
I found this from almost 5 years ago but it doesn't work:
<?php
function check_for_superAdmin($user_login, $user) {
$current_user = get_userdatabylogin($user_login);
if ( is_super_admin( $current_user->ID ) ) {
// do these things
<?php if ( $purchase_code != '' ): ?>
<small class="text-muted form-text">
<?php printf(
__( '<a class="%s" href="#">Click here</a> to dissociate this purchase code from the current domain (use to move the plugin to another site).', 'bookly' ), 'bookly-js-detach-pc'
) ?>
</small>
<?php endif ?>
}
else { // do other things
}
}
add_action( 'wp_login', 'check_for_superAdmin', 10, 2 );
?>
The idea is that only SuperAdmin can mess with the purchase code from Bookly (a non-GPL plugin) but I may reuse the code for other functions.
What do I need to change? What would be the best way to first check that the user has the network admin role?
Thanks,
AG