[wp-hackers] Users for each blog in Multi-Site?

Mike Walsh mpwalsh8 at gmail.com
Wed May 9 18:18:58 UTC 2012

On Wed, May 9, 2012 at 2:11 PM, Paul Menard <paul at codehooligans.com> wrote:

> Mike,
> The key is that under MS a user can have access to more than one blog.
> There are two elements in the usermeta table to look into:
> 1. 'primary_blog' - As the key_name implies this is the user's primary
> blog. Will only contain one blog ID.
> 2. As for when a user can access other blogs the key is in the
> capabilities. If you view the usermeta table for a user you will see a
> record with a meta_key like 'wp_4_capabilities'. This means the user has
> access to blog 4. A given user may have multiple 'wp_XX_capabilities' rows
> where 'XX' is the blog ID. You can access this information simply by using
> the MS function get_blogs_of_user($user_id) see wp-includes/user.php line
> 652. This will return a list of blogs for the user. There is also a
> compliment function is_user_member_of_blog($user_id, $blog_id) for a simple
> user check.
> 2b. There is also a handy function get_blog_details($blog_id) to obtain
> the blog details. Better than a direct query on the blogs table.
> Hope this helps.
> P-
This is exactly what I was looking for, thank you!

Will the primary blog also be present in the meta table as a
wp_XX_capabilities entry?

Mike Walsh - mpwalsh8 at gmail.com

More information about the wp-hackers mailing list