• Resolved Famous

    (@famous)


    How can I add a link to user blogs (MU) in the header so that no matter what blog they are on they can get back to their own blog homepage?

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Famous

    (@famous)

    what function would I use?
    bp_members__blog_directory_permalink();

    Something like the above?

    Thanks

    Looking for specific template tags for BP?
    https://codex.buddypress.org/developer/developer-docs/template-tag-reference/

    Other than that, I’ll offer a couple suggestions:
    First, why not keep the default WP toolbar on the front side with the following snippet in mu-plugins? That way your “My SItes” menu is always on – front and back. All kinds of tips and tricks for customizing the toolbar after that.

    add_filter( 'show_admin_bar', '__return_true' , 1000 );

    Second, using only WP functions I offer you this link to a users primary blog or the dashboard if they do not have a site:

    <?
    	$user_id = get_current_user_id();
    	$active = get_active_blog_for_user( $user_id );
    		if ( $active )
    				$url = get_home_url( $active->blog_id );
    			else
    				$url = get_dashboard_url( $user_id );
    	echo '<a href="'.$url.'">'.$url.'</a>';
    ?>

    Thread Starter Famous

    (@famous)

    Thanks David, your code led me here and it works great!

    <?php
    if(is_user_logged_in()) {
    global $current_user;
      $blogs = get_blogs_of_user( $current_user->id );
         if($blogs) {
         	 foreach ( $blogs as $blog ) {
             echo '<li><a href="https://' . $blog->domain . $blog->path .'">' .  $blog->blogname . '</a></li>';
    		}
         }
    }
    ?>

    Thank you Sir

    Thread Starter Famous

    (@famous)

    Resolved!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Add a link to user blog MU’ is closed to new replies.