Group Mods

  • Profile picture of @mercime
  • Profile picture of r-a-y
  • Profile picture of Hugo

Is there a buddypress conditional tag to show a user’s primary blog? (2 posts)

Started 9 months, 2 weeks ago by: gregfielding

  • Profile picture of gregfielding gregfielding said 9 months, 2 weeks ago:

    something where if a user has created blogs, this will get their primary blog URL?

  • Profile picture of Nahum Nahum said 9 months, 2 weeks ago:

    this was working before 1.5

    function my_blog(){
    	global $bp;
    	if ( !function_exists('bp_blogs_install') )
    		return false;
    
    	if ( !$blogs = wp_cache_get( 'bp_blogs_of_user_' . $bp->displayed_user->id . '_inc_hidden', 'bp' ) ) {
    		$blogs = bp_blogs_get_blogs_for_user( $bp->displayed_user->id, true );
    		wp_cache_set( 'bp_blogs_of_user_' . $bp->displayed_user->id . '_inc_hidden', $blogs, 'bp' );
    	}
    
    	if ( is_array( $blogs['blogs'] ) && (int)$blogs['count'] ) {
    
    	$blog=array_pop($blogs['blogs']);//the first blog
    
    ?>
    
    <li>
    <a href="<?php echo $blog->siteurl; ?>"> <?php _e( 'My Blog', 'buddypress' ) ;?></a>
    </li>
    
    <?php
    }
    }

    I don’t recall now where I found it. If anyone knows how to fix for 1.5 that would be nice.