BP_Blogs_Blog::get_user_blog( int $user_id, int $blog_id )

Get ID of user-blog link.

Description

Parameters

$user_id

(Required) ID of user.

$blog_id

(Required) ID of blog.

Return

(int|bool) ID of user-blog link, or false if not found.

Source

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

689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
public static function get_user_blog( $user_id, $blog_id ) {
    global $wpdb;
 
    $bp = buddypress();
 
    $user_blog = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->blogs->table_name} WHERE user_id = %d AND blog_id = %d", $user_id, $blog_id ) );
 
    if ( empty( $user_blog ) ) {
        $user_blog = false;
    } else {
        $user_blog = intval( $user_blog );
    }
 
    return $user_blog;
}

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.