Advertisements

current_user_can_for_blog

Definition:
function current_user_can_for_blog( $blog_id, $capability ) {}

Whether current user has a capability or role for a given blog.

Parameters

  • int $blog_id: Blog ID
  • string $capability: Capability or role name.

Source code

function current_user_can_for_blog( $blog_id, $capability ) {

	$current_user = wp_get_current_user();



	if ( empty( $current_user ) )

		return false;



	// Create new object to avoid stomping the global current_user.

	$user = new WP_User( $current_user->ID) ;



	// Set the blog id.  @todo add blog id arg to WP_User constructor?

	$user->for_blog( $blog_id );



	$args = array_slice( func_get_args(), 2 );

	$args = array_merge( array( $capability ), $args );



	return call_user_func_array( array( &$user, 'has_cap' ), $args );

}

758

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: