I'd like to only show certain information to users if they are a 'site admin' for site_id 1 (not blog_id).
I'd image the best way to do this would be to query the wp_sitemeta table for meta_value where site_id=1 and meta_key=site_admins
I haven't tested this code, and I don't know mysql/php all too well so I'm not sure if this would work, I'll try back here once I'm able to test. Does anyone see any issues with the code below so far? or is there a better way to do this?
<?php
//get list of siteadmins
$querystr = "
SELECT sadmin.*
FROM $wpdb->wp_sitemeta sadmin
WHERE sadmin.site_id = '1'
AND sadmin.meta_key = 'site_admins'
ORDER BY sadmin.meta_value DESC
";
$siteadmins = $wpdb->get_results($querystr);
//get current user username
global $current_user;
get_currentuserinfo();
$curuname = $current_user->user_login;
//if the currently logged in user is a site admin show info
if (in_array($curuname, $siteadmins)) {
echo("This user is a siteadmin for the main site");
}
?>
How would I make a function out of this for a conditional statement?
Thanks in advance for any help.