In a multisite, how can I get the ID of the owner of the current blog?

I know how to get the current blogs Id using get_current_blog_id(), so given that ID, how would I fetch the ID of the owner of that blog? (there's just one owner per blog.)

2 Answers 2


I use this workaround to get the ID of the owner of the current blog:

$thisblog = $current_blog->blog_id;
$mail = get_blog_option($thisblog, 'admin_email');
$user_from_email = get_user_by('email', $mail);
$user_id = $user_from_email->ID;

I came up with this solution for a direct query, but I'd still like to know if there's a template tag I've missed.

$blog_id = get_current_blog_id();

$querystring = "SELECT `user_id`
                FROM `wp_usermeta`
                WHERE (meta_key LIKE 'primary_blog' AND meta_value LIKE $blog_id) 
                LIMIT 1";

$blogownerid = $wpdb->get_var($querystring);
  • You can use get_users() and pass the blog id and "administrator" role, but that makes a slower query Dec 11, 2011 at 18:32
  • To better support WP multisite and prevent SQL injection attacks, I'd actually recommend something like $wpdb->get_var($wpdb->prepare("SELECT `user_id` FROM `$wpdb->usermeta` WHERE `meta_key` = 'primary_blog' AND `meta_value` = %d LIMIT 1", array($blog_id)))
    – rinogo
    Nov 23, 2016 at 22:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.