User blogs

//Call the function from the members-loop.php file within the members loop
<?php lmc_get_user_blogs(bp_get_member_user_id());?>

//Add to your functions.php file
function lmc_get_user_blogs($user_id){
global $wpdb;

$blog_query = $wpdb->get_results("SELECT blog_id FROM wp_bp_user_blogs
WHERE user_id = $user_id");
if(!$blog_query) return;
else echo bp_member_name() . ''s Blogs:</span>';
foreach($blog_query as $blog){
if($blog->blog_id == 1) continue;
$domain_query = $wpdb->get_results("SELECT domain FROM wp_blogs
WHERE blog_id = $blog->blog_id");
$complete_url = $domain_query[0]->domain;
$pos = strpos($complete_url,'.');
$subdomain = substr_replace($complete_url,"",$pos);
<a class="lmc-blog-link" href="<?php echo 'http://' . $complete_url ?>" title="Visit Blog"><?php echo $subdomain ?></a>

1 Comment

You must be logged in to post a comment.

  1. [...] copied from: This entry was posted in buddypress, wordpress. Bookmark the permalink. Post a comment or leave a [...]