Skip to:
Content
Pages
Categories
Search
Top
Bottom

new blog post in site wide activity stream but not in personal activity stream


  • teruun
    Participant

    @teruun

    The blog-post(wp-post) was not appearing in the activity stream out of the box in my installation of buddypress. So i added a piece of code in bp-acitivity-actions.php:

    function buddypress_edit_blog_post($post_id) {
         global $bp, $user_id;
         $post = get_post($post_id); 
         $title = $post->post_title;
         $user_fullname  = bp_core_get_user_displayname($user_id);
    
         bp_activity_add(array(
        'action' => $user_fullname.' updated ' . $title . ':',
        'component' => 'blog_post',
        'type' => 'update_post',
        'primary_link' => get_permalink($post_id),
        'user_id' => $user_id,
        'content' => $post->post_content
         ));
    
    }
    add_action('edit_post', 'buddypress_edit_blog_post');

    and now the site wide activity is displaying user’s new blog-post, however, I still can’t see it in personal activity stream.
    I don’t understand, why does this happen?
    And I want to know which piece of code is managing the personal activity stream, I would like to know how it works.

    Thanks.

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

  • Henry Wright
    Moderator

    @henrywright

    I don’t think you can do global $user_id;. So when adding your activity, $user_id isn’t what you expect it to be.


    teruun
    Participant

    @teruun

    Thanks, @henrywright
    So i changed my code to this:

    function buddypress_edit_blog_post($post_id) {
         global $bp; //, $user_id;
         $user_id = wp_get_current_user();
         $post = get_post($post_id); 
         $title = $post->post_title;
         $user_fullname  = bp_core_get_user_displayname($user_id);
    
         bp_activity_add(array(
        'action' => $user_fullname.' updated ' . $title . ':',
        'component' => 'blog_post',
        'type' => 'update_post',
        'primary_link' => get_permalink($post_id),
        'user_id' => $user_id,
        'content' => $post->post_content
         ));
    
    }
    add_action('edit_post', 'buddypress_edit_blog_post');

    I don’t know is it right to use wp_get_current_user() function. But the personal activity stream still doesn’t have my blog post, and the site wide activity stream still has.

    What should I try next?
    Thanks.


    teruun
    Participant

    @teruun

    And i want to know how buddypress handles with personal activity stream, where is the filter? What process it has until the streams displayed on the page? Could you please provide me some documentation or tutorial about this? Or just tell me which part of the code does this.
    I’m a little confused about how buddypress works.
    Thanks again.


    teruun
    Participant

    @teruun

    I tested the userid returned by wp_get_current_user() with
    var_dump("test user_id:".$user_id);
    , but nothing displays on the activity page, even the string “test user_id:”, so I really need your help.
    Thanks…


    Henry Wright
    Moderator

    @henrywright

    Have a read of the Playing with the user’s ID in different contexts article. It should give you an idea how to get the user’s ID in many of the different situations you’ll come across when using BP.

    Take for example the logged in user, you can use bp_loggedin_user_id() to get their ID.


    teruun
    Participant

    @teruun

    Yes, it works!
    Thank you.

    Problem solved. Do i need to close this topic? I can’t find any button to close it…

    Thanks for your reply!


    Henry Wright
    Moderator

    @henrywright

    Great to see you got it working!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘new blog post in site wide activity stream but not in personal activity stream’ is closed to new replies.
Skip to toolbar