Re: Suggestion: “My Blogs” should show ALL blogs I'm a member of
It looks like this (out of date for 1.3) how-to addresses what I want…
https://codex.buddypress.org/how-to-guides/modifying-the-buddypress-admin-bar/
When I run it, though, I get an unexpected $end, and I’ve managed to work it down to this:
// sort array of blog objs by $blog->role according to the order of $blog_roles
// roles not included in $blog_roles array will not be displayed
function filter_blogs_by_role($blogs) {
global $bp, $blog_roles;
$blog_roles[] = __( 'Admin', 'buddypress' );
$blog_roles[] = __( 'Editor', 'buddypress' );
$blog_roles[] = __( 'Author', 'buddypress' );
$blog_roles[] = __( 'Contributor', 'buddypress' );
$blog_roles[] = __( 'Subscriber', 'buddypress' );
// get roles
foreach ($blogs as $blog) {
$blog->role = get_blog_role_for_user( $bp->loggedin_user->id, $blog->userblog_id );
}
// eliminate roles not in $blog_roles
foreach ($blogs as $key => $value) {
if (!in_array($value->role, $blog_roles))
unset($blogs[$key]);
}
// sort by $blog_roles sequence if there are any left
if ($blogs) {
usort($blogs, 'compare_roles');
}
return $blogs;
}
It’s bombing out on this line $blog->role = get_blog_role_for_user( $bp->loggedin_user->id, $blog->userblog_id );
with Warning: Attempt to assign property of non-object in /home/conrel/public_html/wp-content/plugins/bp-custom.php on line 72 (that is, that line is #72).
I’m not quite sure what it’s doing there, but I’m working on it.