Skip to:
Content
Pages
Categories
Search
Top
Bottom

Link to users blog.


  • PhillipSonderskov
    Member

    @phillipsonderskov

    Hi. I’ve been searching here and in my php files for this, but couldn’t find it.
    The issue:
    Once a user has logged in to my bp-site, i want to add a link to his/her wp-blog, similar to the link in the adminbar.
    (ex: for user one – http://www.mypage.com/user1 and for user2 – http://www.mypage.com/user2)

    I know where to write the code, once i find it, i just can’t figure out what the code is :S

    Hope that any one can help!

    Thanks!
    -Phillip

Viewing 4 replies - 1 through 4 (of 4 total)

  • PhillipSonderskov
    Member

    @phillipsonderskov

    Oh. And the code will be placed in the sidebar, so it is displayed on every side..


    Bowe
    Participant

    @bowromir

    I think placing the following code at the bottom of functions.php of your child theme should do the trick:

    `
    /* Creates Blog navigation for Accordeon Menu */
    function my_blog_menu(){
    global $bp;
    if ( !is_user_logged_in() || !function_exists(‘bp_blogs_install’) )
    return false;
    //two lines from bp_adminbar_blogs_menu() in bp-core-adminbar.php

    if ( !$blogs = wp_cache_get( ‘bp_blogs_of_user_’ . $bp->loggedin_user->id . ‘_inc_hidden’, ‘bp’ ) ) {
    $blogs = bp_blogs_get_blogs_for_user( $bp->loggedin_user->id, true );
    wp_cache_set( ‘bp_blogs_of_user_’ . $bp->loggedin_user->id . ‘_inc_hidden’, $blogs, ‘bp’ );
    }

    if ( is_array( $blogs ) && (int)$blogs ) {

    $blog=array_pop($blogs);//the first blog

    ?>
    <a href="siteurl; ?>”>

    `
    After you’ve put this in your functions.php add the following to sidebar.php to call the function:

    “`

    Thanks to @sbrajesh for this snippet :)


    PhillipSonderskov
    Member

    @phillipsonderskov

    Works like a charm! :D

    Thanks man! and thank you @sbrajesh

    hi. has anyone found a way to get this snippet to work with bp 1.5?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Link to users blog.’ is closed to new replies.
Skip to toolbar