Skip to:
Content
Pages
Categories
Search
Top
Bottom

bbPress 2: Manual activity stream integration


  • will_c
    Participant

    @will_c

    I have a fresh BP 1.5.1 install with the bbPress 2 sitewide plugin installed. I have tried a number of different configurations (ie installing forums through the BP installer, then adding sitewide forums and disabling the forum component, keeping the forum component installed and using the sitewide plugin, or simply forgoing the forum install in the wizard and adding the plugin manually), but wasn’t able to get the activity stream integration with any of them.

    However, I was able to write my own hacked version of the functionality into my functions.php file and it works. I modeled my code off the /wp-content/plugins/bbpress/bbp-includes/bbp-extend-buddypress.php file starting at line 399. Because I am basically copying the functionality of the bbp-extend-buddypress.php file, I am wondering if maybe the bbp-extend-buddypress.php file simply isn’t being called, or if it’s a larger issue.

    For those that are having similar issues, here’s the code I put together (warning, it’s quite hacked together and may not work for everyone). You can follow the same model for a new topic post by using the bbp_new_topic hook:

    function bpt_reply_activity($reply_id = 0, $topic_id = 0, $forum_id = 0) {
    $reply_id = bbp_get_reply_id($reply_id);
    $user_fullname = bbp_get_user_profile_link(bbp_get_current_user_id());
    $topic_link = '<a href="' . bbp_get_topic_permalink($topic_id) . '" title="' . bbp_get_topic_title($topic_id) . '">' . bbp_get_topic_title($topic_id) . '</a>';
    $forum_link = '<a href="' . bbp_get_forum_permalink($forum_id) . '" title="' . bbp_get_forum_title($forum_id) . '">' . bbp_get_forum_title($forum_id) . '</a>';
    $my_content = bbp_get_reply_content($reply_id);
    $reply_url = bbp_get_reply_url($reply_id);
    $user_id = bbp_get_current_user_id();

    $max_length = 500;
    if(strlen($my_content) > $max_length) {
    $my_content = substr($my_content, 0, $max_length);
    $my_content = $my_content . "[...]";
    }

    $the_action = " posted in the topic ";

    bp_activity_add(array(
    'user_id' => $user_id,
    'type' => 'new_forum_post',
    'action' => ''. $user_fullname . '' . $the_action . '' . $topic_link . ' in the forum ' . $forum_link . ':',
    'item_id' => $topic_id,
    'secondary_item_id' => $forum_id,
    'content' => $my_content,
    'primary_link' => $reply_url,
    'component' => 'bbpress',
    'recorded_time' => bp_core_current_time(),
    'hide_sitewide' => false
    ));

    return;
    }
    add_action('bbp_new_reply', 'bpt_reply_activity');

Viewing 5 replies - 1 through 5 (of 5 total)
  • I have been looking for this for DAYS!!!!!!

    You are awesome!

    Forgive me for my lack of knowledge.. where do I put the “bbp_new_topic” ?

    Thank you! Thank you! Thank you!


    will_c
    Participant

    @will_c

    You can just copy the function but replace reply with topic. I’ve pasted the code below. So you’d have two functions, one for replies and one for topics:

    function bpt_topic_activity($topic_id = 0, $forum_id = 0) {
    $topic_id = bbp_get_topic_id($topic_id);
    $user_fullname = bbp_get_user_profile_link(bbp_get_current_user_id());
    $topic_link = '<a class="topic_link" href="' . bbp_get_topic_permalink($topic_id) . '" title="' . bbp_get_topic_title($topic_id) . '">' . bbp_get_topic_title($topic_id) . '</a>';
    $forum_link = '<a class="forum_link" href="' . bbp_get_forum_permalink($forum_id) . '" title="' . bbp_get_forum_title($forum_id) . '">' . bbp_get_forum_title($forum_id) . '</a>';
    $my_content = bbp_get_topic_content($topic_id);
    $user_id = bbp_get_current_user_id();
    $the_action = " created the topic ";

    bp_activity_add(array(
    'user_id' => $user_id,
    'type' => 'new_forum_topic',
    'action' => ''. $user_fullname . '' . $the_action . '' . $topic_link . '<span class="activity_forum_link"> in the forum ' . $forum_link . '</span>',
    'item_id' => $topic_id,
    'secondary_item_id' => $forum_id,
    'content' => $my_content,
    'component' => 'bbpress',
    'recorded_time' => bp_core_current_time(),
    'hide_sitewide' => false
    ));

    return;
    }
    add_action('bbp_new_topic', 'bpt_topic_activity');

    AWESOME!!!!!!!!!!!!! There are a lot of people looking for this! I will keep your link in case I come across more. You have put an end to my headache!!! :) Thank you!


    Jeff
    Member

    @splatterrific

    Hi, I am in the same exact problem. Which functions.php file do you add this to?


    John James Jacoby
    Keymaster

    @johnjamesjacoby

    Most of this comes already baked into bbPress 2.1. No reason to duplicate these efforts.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘bbPress 2: Manual activity stream integration’ is closed to new replies.
Skip to toolbar