@scroobyfe
Not recently active
Forum Replies Created
Viewing 1 replies (of 1 total)
-
I’ve managed to resolve my issue. For anyone who is looking to do something similar, this is what I did.
I was going to resort to creating a custom database query for retrieiving all the users blogs until I dug into the BuddyPress plugin and found the function that is used within the admin area that lists all the blogs that each user is a member of.
I used the ‘get_blogs_of_user’ function found in ms-functions.php:
<br />
<?php<br />
global $bp;<br />
$userID = $bp->loggedin_user->id;<br />
$blogs = get_blogs_of_user( $userID, true );
// Check if blogs have been returned
if(!empty($blogs)){
?>
<ul id="blogs-list" class="item-list">
<?php
if ( is_array( $blogs ) ) {
foreach ( (array) $blogs as $key => $val ) {
if($val->userblog_id == 1){ continue; }
$blogLink = "http://".$val->domain . $val->path;
$blogName = $val->blogname;
?>
<li>
<div class="item">
<div class="item-title"><a>"><?php echo $blogName; ?> Videos</a></div>
<div class="generic-button blog-button visit">
<a>" class="visit" title="<?php _e( 'View Videos', 'buddypress' ) ?>"><?php _e( 'View Videos', 'buddypress' ) ?></a>
</div>
</div>
<div class="action">
<?php do_action( 'bp_directory_blogs_actions' ) ?>
</div>
<div class="clear"></div>
</li>
<?php
} // End loop
} // End if
?>
<?php do_action( 'bp_after_directory_blogs_list' ) ?>
<?php bp_blog_hidden_fields() ?>
<?php } else { // If no blogs have been returned ?>
<div id="message" class="info">
<?php _e( 'Sorry, there were no blogs found.', 'buddypress' ) ?>
</div>
<?php } // End if ?>This code will list all of the blogs that the current logged in user is a member of, no matter what role the user has, admin, editor, subscriber etc.
Viewing 1 replies (of 1 total)