BP_Blogs_Blog::get_blog_ids_for_user( int $user_id )

Get IDs of all of a user’s blogs, as tracked by BuddyPress.

Description

This method always includes hidden blogs.

Parameters

$user_id

(Optional) ID of the user whose blogs are being queried. Defaults to logged-in user.

Return

(int) The number of blogs associated with the user.

Source

File: bp-blogs/classes/class-bp-blogs-blog.php

401
402
403
404
405
406
407
408
409
410
public static function get_blog_ids_for_user( $user_id = 0 ) {
    global $wpdb;
 
    $bp = buddypress();
 
    if ( !$user_id )
        $user_id = bp_displayed_user_id();
 
    return array_map( 'intval', $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM {$bp->blogs->table_name} WHERE user_id = %d", $user_id ) ) );
}

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.