I am working on creating a function that will take a $blog_id
and return the corresponding $user_id
of the user who owns/created the blog in a multi site network.
public function SelectOwnerUserIdFromBlogId( $blog_id ) { ... }
I have been reviewing the database and the closest thing I can find is looking at the wp_usermeta table and filtering on capabilities but this feels too hackish. Any better idea?
SELECT user_id as UserId,
IF(SUBSTRING_INDEX(SUBSTRING_INDEX(meta_key, '_', 2), '_', -1) = 'capabilities', 1, SUBSTRING_INDEX(SUBSTRING_INDEX(meta_key, '_', 2), '_', -1)) as BlogId
FROM wp_usermeta
WHERE meta_key like '%_capabilities'
AND meta_value like '%administrator%'