WordPress.org

Ready to get started?Download WordPress

Codex

Function Reference/is user member of blog

Contents

Description

Find out whether a user is a member of a given blog.

Usage

<?php is_user_member_of_blog$user_id$blog_id ); ?>

Parameters

$user_id
(integer) (optional) User ID to check membership
Default: current user
$blog_id
(integer) (optional) Blog ID to check membership
Default: current blog

Return Value

(boolean) 
True if member, False if not

Examples

Check if the current user is a member of blog 5:

<?php

$user_id = get_current_user_id();
$blog_id = 5;

if ( is_user_member_of_blog( $user_id, $blog_id ) {

   /*
    * The user is a member of the blog with ID 5.
    * We could do stuff here, like show them a link, etc.
    */
}

?>

Notes

Change Log

Since: MU

Source File

is_user_member_of_blog() is located in wp-includes/user.php

Related

Blog User Functions: add_user_to_blog(), add_new_user_to_blog(), remove_user_from_blog(), is_user_member_of_blog()

See also index of Function Reference and index of Template Tags.