get_blogs_of_user [ WordPress Function ]
get_blogs_of_user ( $user_id, $all = false )
| Parameters: |
|
| Returns: |
|
| Defined at: |
|
Soorgelijke functies: get_active_blog_for_user, get_blog_post, get_blog_count, get_blog_id_from_url, is_blog_user
Get the blogs a user belongs to.
Source
<?php
function get_blogs_of_user( $user_id, $all = false ) {
global $wpdb;
$user_id = (int) $user_id;
// Logged out users can't have blogs
if ( empty( $user_id ) )
return array();
$keys = get_user_meta( $user_id );
if ( empty( $keys ) )
return array();
if ( ! is_multisite() ) {
$blog_id = get_current_blog_id();
$blogs = array( $blog_id => new stdClass );
$blogs[ $blog_id ]->userblog_id = $blog_id;
$blogs[ $blog_id ]->blogname = get_option('blogname');
$blogs[ $blog_id ]->domain = '';
$blogs[ $blog_id ]->path = '';
$blogs[ $blog_id ]->site_id = 1;
$blogs[ $blog_id ]->siteurl = get_option('siteurl');
return $blogs;
}
$blogs = array();
if ( isset( $keys[ $wpdb->base_prefix . 'capabilities' ] ) && defined( 'MULTISITE' ) ) {
$blog = get_blog_details( 1 );
if ( $blog && isset( $blog->domain ) && ( $all || ( ! $blog->archived && ! $blog->spam && ! $blog->deleted ) ) ) {
$blogs[ 1 ] = (object) array(
'userblog_id' => 1,
'blogname' => $blog->blogname,
'domain' => $blog->domain,
'path' => $blog->path,
'site_id' => $blog->site_id,
'siteurl' => $blog->siteurl,
);
}
unset( $keys[ $wpdb->base_prefix . 'capabilities' ] );
}
$keys = array_keys( $keys );
foreach ( $keys as $key ) {
if ( 'capabilities' !== substr( $key, -12 ) )
continue;
if ( $wpdb->base_prefix && 0 !== strpos( $key, $wpdb->base_prefix ) )
continue;
$blog_id = str_replace( array( $wpdb->base_prefix, '_capabilities' ), '', $key );
if ( ! is_numeric( $blog_id ) )
continue;
$blog_id = (int) $blog_id;
$blog = get_blog_details( $blog_id );
if ( $blog && isset( $blog->domain ) && ( $all || ( ! $blog->archived && ! $blog->spam && ! $blog->deleted ) ) ) {
$blogs[ $blog_id ] = (object) array(
'userblog_id' => $blog_id,
'blogname' => $blog->blogname,
'domain' => $blog->domain,
'path' => $blog->path,
'site_id' => $blog->site_id,
'siteurl' => $blog->siteurl,
);
}
}
return apply_filters( 'get_blogs_of_user', $blogs, $user_id, $all );
}
?>
Examples [ wp-snippets.com ]
Top Google zoekresultaten
- WPMU Functions/get blogs of user « WordPress Codex
Description. Returns an array of objects containing the details of each blog the specified user has access to. Parameters. $id: (integer) (required) ID of user ...
codex.wordpress.org - Fatal error: Call to undefined function get_blogs_of_user()...class-wp ...
I had everything current and running smoothly until I partially installed an older backup file from Dreamweaver. I have fixed many of the error messages that I ...
wordpress.org - PHPXRef 0.7 : WordPress : Function Reference: get_blogs_of_user()
get_blogs_of_user(). Defined at: /wp-includes/user.php -> line 648. Referenced 19 times: /wp-admin/my-sites.php -> line 20 · /wp-includes/link-template.php ...
phpxref.ftwr.co.uk - get_blogs_of_user() WordPress function reference, arguments and ...
get_blogs_of_user( $user_id, $all = false ). user_id: (int) User ID; all: (boolean) Whether to retrieve all blogs, or only blogs that are not marked as deleted, ...
queryposts.com