Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to get a user's last update?


  • m@rk
    Participant

    @mrk-1

    In BP 1.1 you could get a user’s last “status update” with:

    get_usermeta( $user_id, 'bp_status' );

    Does anybody know how to get a user’s last “update” in BP 1.2 now? I’ve been looking through bp-core-classes.php, searching for something like

    $author = new BP_Core_User( $user_id);

    echo $author->user_update;

    to work… no success.

    Thanks in advance.

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

  • Brajesh Singh
    Participant

    @sbrajesh

    hi Mark, this has changed in bp 1.2

    try this one

    bp_activity_latest_update($user_id);

    Change the user Id with the user’s id whose last update you want.

    btw, this should also work

    $update=get_usermeta( $user_id, 'bp_latest_update' );
    echo $update;

    Hope it helps.


    m@rk
    Participant

    @mrk-1

    Thank you Brajesh.

    bp_activity_latest_update($user_id); works but directly echos in quotes and with a “View” link added.

    Your second suggestion returns “Array”. This should point to a way to simply get the string. Do you know which index would return the status? Some kind of echo $update[‘status’] ?


    Brajesh Singh
    Participant

    @sbrajesh

    hi Mark

    You are most welcome. I am sorry I missed that and thought the second line will just work.

    hmm, you can use this one though with the get_usermeta thing

    $update=get_usermeta( $user_id, 'bp_latest_update' );

    echo $update['content'];


    m@rk
    Participant

    @mrk-1

    Works! Thank you very much for your proper assistance Brajesh!

    (I’m wondering why we can’t get this out of a BP_Core_User instance?)


    andrewsa
    Participant

    @andrewsa

    Hi,

    I hate to hijack this thread, but I am trying to include user’s status from their respective post, from main page posts, and I am unable to do so. I only get a blank response. I can include code if needed.


    m@rk
    Participant

    @mrk-1

    Hi andrewsa,

    you have to give a valid $user_id at least. I’m using this in my blog’s sidebar, have a look at http://spaces.nordblog.net/mark/ in the upper right corner.

    I defined in blog theme’s functions.php:

    function bp_author_info( $title, $user_id){

    // Fetch some ...
    // Get author's data BuddyPress style:
    $author = new BP_Core_User( $user_id);

    // Make output ...
    echo "<!-- Status Updates -->
    <h2>{$title}</h2>
    <ul><li>
    <span class=\"alignleft\">
    <a href=\"{$author->user_url}\" title=\"Profil von {$author->fullname}\">{$author->avatar_thumb}</a>
    </span>\n";
    bp_activity_latest_update( $user_id); // contains echo with View link
    echo "<span style=\"display: block; clear: both;\"><!-- clear --></span>
    </li></ul>\\n";

    }

    … and inserted in sidebar.php:

    if( function_exists( 'bp_author_info')){
    bp_author_info( $title = "Mensch", $userid = 2 );
    }

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to get a user's last update?’ is closed to new replies.
Skip to toolbar