I use WordPress Multisite and in the sidebar i have a box that shows a list of blogs the logged in user is a member of.
I’m looking for a way to exclude the mainblog from this list.
The main blog ID is 1
Here is parts of the code I use:
<?php // Gets user-info ?>
<?php global $current_user; get_currentuserinfo();
$user_info = get_userdata(1);
$user_id = $current_user->ID;
?>
<?php // start the loop ?>
<?php $user_blogs = get_blogs_of_user( $user_id ); echo '<div>'; foreach ($user_blogs AS $user_blog) { echo '';?>
<?php // lists user blogs ?>
<?php echo ''.$user_blog->blogname.' '; ?>
Can anyone help me? 🙂
If you drop this line in your code, you will see all the properties of $user_blogs.
echo '<pre>'.print_r($user_blogs,true).'</pre>';
One of them is
userblog_id
, so you just have to check against it before echoing the blogname.