BuddyDev

Search

[Resolved] bp_activity_add not showing profile image

  • Participant
    Level: Master
    Posts: 413
    Venutius on #13160

    Hi Brajesh, I’m working on my first BuddyPress plugin. This one is to add post updates to the activity feed.

    I have one problem I can’t seem to fix, in that I’m getting the post update in the activity feed, however whilst it’s showing the username it’s not showing the users profile picture.

    Here’s my code:

    function bpu_buddypress_edit_post($post_id) {
    
         global $bp, $user_id;
         $post = get_post($post_id); 
         $title = $post->post_title;
         $user_fullname  = bp_core_get_user_displayname($post->post_author);
    
         $bp_activity_id = bp_activity_add(array(
            'action' => $user_fullname.' updated ' . $title . ':',
    	'content' => $post->post_excerpt,
            'component' => 'blogs',
            'type' => 'activity_update',
            'primary_link' => "<strong>" + get_permalink($post_id) + "</strong>",
            'user_id' => $user_id,
            'item_id' => $post->ID
         ));
    }
    add_action('edit_post', 'bpu_buddypress_edit_post');

    As you can see I’m getting the user id from the post author, this seems to work in that it’s showing the correct displayname, but not the users profile image.

    Any ideas why this is not working?

  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #13164

    Hi George,
    Please try changing

    
    'user_id' => $user_id,
    

    to

    
    'user_id' => $post->post_author,
    

    and see if that makes any change.

  • Participant
    Level: Master
    Posts: 413
    Venutius on #13167

    Thanks Brajesh, that worked!

  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #13168

    Wow, That was fast 🙂

  • Participant
    Level: Master
    Posts: 413
    Venutius on #13171

    Hi Brajesh, sorry to bother you but I have another related question.

    With the above code the post title is not a clickable link and neither is the post authors name. but for a new pst entry in Activity these are clickable. How would I achieve the same? I’ve tried no end of <a href combinations but while they do not cause an error neither do they deliver the required result.

    Thanks

  • Participant
    Level: Master
    Posts: 413
    Venutius on #13183

    I’ve sorted this one now.

  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #13184

    Hi George,
    Sorry I could not assist earlier.
    Glad that you found a solution.

    Best Regards
    Brajesh

  • Participant
    Level: Master
    Posts: 413
    Venutius on #13185

    I was simple syntax, I left it for a while then when I came back I was able to fix it in one.

  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #13187

    🙂

You must be logged in to reply to this topic.

This topic is: resolved