Hey, I wish to display each user on the header links to blogs that he has rights on.
apparently there isnt a userrights table but mu uses the usermeta table. is there any plugin that i can use that shows the blogs that the current logged user has rights on?
i tried this string :
get_currentuserinfo();
global $userdata;
$values = array();
$sql="SELECT * FROM wp_usermeta WHERE (user_id = ''. $user->ID .'' AND meta_key LIKE '_capabilities')";
thing is that there isnt a constant metavalue value that i can take as the blog id that the user has rights on.
what should i do? someone told me to use explode? is that correct?
That would be pretty great, to show an overview of your blogs. Doesn't WP.com do this?
Well, in the admin area, when you list all blogs or users maybe, the chart shows who is associated with what. So I'd go look at the file that generates that page and see what code they used there.
thats a great idea. i'll look into it right now.
<?php
$query = "SELECT *
FROM ".$wpdb->users."
WHERE ID = '".$_GET[ 'id' ]."'";
$userdetails = $wpdb->get_results( $query, ARRAY_A );
$query = "SELECT *
FROM ".$wpdb->usermeta."
WHERE user_id = '".$_GET[ 'id' ]."'";
$usermetadetails= $wpdb->get_results( $query, ARRAY_A );
?>
Thats the query and i guess theres a few loops that match the data
<?php
while( list( $key, $val ) = each( $usermetadetails ) ) {
if( substr( $val[ 'meta_key' ], -12 ) == 'capabilities' )
return;
?>
<?php if( is_array( $blogs ) )
while( list( $key, $val ) = each( $blogs ) ) {
print 'userblog_id . '">' . str_replace( '.' . $current_site->domain, '', $val->domain ) . ' (<a ';
if( get_blog_status( $val->userblog_id, 'spam' ) == 1 )
print 'style="background-color: #f66" ';
print 'target="_new" href="http://'.$val->domain . $val->path.'">' . __('View') . ')<BR>';
} ?>
this is the loop for displaying the blogs related to the line of the user
Well apparently there are hidden hooks that a user can use.
Here is the code to retrieve the blogs a user got rights on
You can pass get_blogs_of_user any ID to retrieve the blogs that the user got rights on.
<?php
$blogs = get_blogs_of_user($current_user->ID);
if ( ! empty($blogs) ) foreach ( $blogs as $blog ) {
echo "
domain . $blog->path . "'>" . $blog->domain . $blog->path . "
";
}
?>