bbPress 2: Manual activity stream integration
-
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');
- The topic ‘bbPress 2: Manual activity stream integration’ is closed to new replies.