Skip to:
Content
Pages
Categories
Search
Top
Bottom

Displaying User Avatar with activity

  • @logixz

    Member

    Hi all, Im a bit of a php newbie so bare with me :) What Im trying to accomplish is pull the last 20 activities from the database and display the user avatar associated with the activity. I believe Im on the right path but Im not really sure where to go from here. Here is what I have in my functions.php file thus far. Any help would be much appreciated! Thanks

    ‘function last_activities($num = 20) {
    global $wpdb, $bp;
    $results = $wpdb->get_results( $wpdb->prepare( “SELECT * FROM {$bp->activity->table_name} ORDER BY id DESC LIMIT 20”, $num ) );
    return $results;
    }’

Viewing 4 replies - 1 through 4 (of 4 total)
  • @modemlooper

    Moderator

    Not that easy, the avatar is not saved in the db. It’s found by user id and a combo of avatar folder urls.

    Each user has a folder in avatars with the id of user as name. The avatars image names are created from a hash of the timestamp.

    @logixz

    Member

    @modemlooper understood, I was thinking that since that SQL queries pulls the userid I could somehow tie in bp_core_fetch_avatar into the equation?

    @modemlooper

    Moderator

    Try, I think that fetch function only works in a loop. I’m having similar problems with creating json API and getting avatars. Another option is to write code to cycle through a folder and get the contents. Since each folder is a user id you could get id from activity table and then write a function to get the users images from that folder.

    @logixz

    Member

    Yeah, sounds like this is going to be a little over my head :(

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Displaying User Avatar with activity’ is closed to new replies.
Skip to toolbar