A A A

Please consider registering
guest

Log In Register

Register | Lost password?
Advanced Search:

— Forum Scope —



— Match —



— Forum Options —




Wildcard usage:
*  matches any number of characters    %  matches exactly one character

Minimum search word length is 4 characters - maximum search word length is 84 characters

Topic RSS
Integrating Simple:Press into BuddyPress Activity Stream
Aug 13, 2010
4:35 pm
Member
Forum Posts: 77
Member Since:
Sep 20, 2009
Offline

Sure! Here is the final code chunk:

 

 function sf_hook_post_save($newpost, $action)
 {
   global $bp;
   global $current_user;
   
   if ($newpost['forumid'] == 1 OR $newpost['forumid'] == 2 OR $newpost['forumid'] == 3 OR $newpost['forumid'] == 4 OR $newpost['forumid'] == 5 OR $newpost['forumid'] == 6 OR $newpost['forumid'] == 7 OR $newpost['forumid'] == 8 OR $newpost['forumid'] == 11)
            {
            // Only allowed forum id's can post to the BP Activity
   
   
   $activity = new BP_Activity_Activity();
   $date_recorded = date('Y-m-d H:i:s', strtotime('+6 hours'));
   $user_fullname  = bp_core_get_user_displayname($newpost['userid']);
   $username = bp_core_get_username($newpost['userid']);
   
   $topic_title = sf_get_topic_name_from_id($newpost['topicid']);
   
   
   //$topic_title = $newpost['topic_slug'];
   $mycontent = $newpost['postcontent'];
   $max_length = 300;
     if(strlen($mycontent) > $max_length)
     {
$mycontent = substr($mycontent,0,$max_length);
$mycontent = $mycontent . ".....";
     }
   if ($action=="topic") { $the_action = " created the topic "; } else { $the_action = " posted in the topic "; }
   $activity = new BP_Activity_Activity ();
   $activity->user_id = $newpost['userid'];
   $activity->component = "simplepress";
        $activity->type = "new_forum_post";
   $activity->action = ''.$user_fullname.'' . $the_action . '' . $topic_title . ':';
   $activity->content = $mycontent;
   $activity->primary_link = $newpost['url'];
   $activity->secondary_item_id = '';
   $activity->date_recorded = $date_recorded;
   $activity->hide_sitewide = 0;
   $activity->save ();
   
   } else {
   // Do NOT post private forum post to feed
   }    
 
   return;
 }
Aug 13, 2010
6:06 pm

SP Master
Forum Posts: 23688
Member Since:
Dec 10, 2006
Offline

great! thanks!

Aug 15, 2010
11:30 am
Member
Forum Posts: 77
Member Since:
Sep 20, 2009
Offline

Mm, can't edit my post. I changed it up a little since I only have 3 forums that are protected. I also did a post on my blog about this for future reference for myself as well. Credit goes to you guys of course ;)

 

Guess it depends if you have more public or private forums. Do whatever you have less of and switch it around to your needs. 

 

 function sf_hook_post_save($newpost, $action)
 {
   global $bp;
   global $current_user;
   
   if ($newpost['forumid'] == 9 OR $newpost['forumid'] == 10 OR $newpost['forumid'] == 12)
            {
            // Put in the forum id's you do NOT want to show up in the  BP activity stream
   
   } else {
   // Post SPF Post to BP Activity Stream
   
   $activity = new BP_Activity_Activity();
   $date_recorded = date('Y-m-d H:i:s', strtotime('+6 hours'));
   $user_fullname  = bp_core_get_user_displayname($newpost['userid']);
   $username = bp_core_get_username($newpost['userid']);
   
   $topic_title = sf_get_topic_name_from_id($newpost['topicid']);
   
   
   //$topic_title = $newpost['topic_slug'];
   $mycontent = $newpost['postcontent'];
   $max_length = 300;
     if(strlen($mycontent) > $max_length)
     {
$mycontent = substr($mycontent,0,$max_length);
$mycontent = $mycontent . ".....";
     }
   if ($action=="topic") { $the_action = " created the topic "; } else { $the_action = " posted in the topic "; }
   $activity = new BP_Activity_Activity ();
   $activity->user_id = $newpost['userid'];
   $activity->component = "simplepress";
        $activity->type = "new_forum_post";
   $activity->action = ''.$user_fullname.'' . $the_action . '' . $topic_title . ':';
   $activity->content = $mycontent;
   $activity->primary_link = $newpost['url'];
   $activity->secondary_item_id = '';
   $activity->date_recorded = $date_recorded;
   $activity->hide_sitewide = 0;
   $activity->save ();    
   
   }    
 
   return;
 }
Aug 15, 2010
8:16 pm

SP Master
Forum Posts: 23688
Member Since:
Dec 10, 2006
Offline

nice work!  sure others will find this useful.  make a great plugin in v5!

Aug 27, 2010
12:28 pm
Member
Forum Posts: 77
Member Since:
Sep 20, 2009
Offline

mm, I wonder if there is a way to have it not display photos in the activity feed..

Sep 22, 2010
10:52 am
Member
Forum Posts: 77
Member Since:
Sep 20, 2009
Offline

[IMPORTANT UPDATE]

 

After a month of heavy use I notice sometimes it would break the activity filter. So I was forced to remove the content from the activity feed. Just comment out this line like so:

 

//$activity->content = $mycontent;
Sep 23, 2010
3:54 am

SP Master
Forum Posts: 22240
Member Since:
Nov 9, 2008
Offline

Thanks for the news. We will be looking long and hard at BuddyPress quite soon, especially for our planned Version 5.

Yellow Swordfish
Sep 23, 2010
7:42 am
Member
Forum Posts: 77
Member Since:
Sep 20, 2009
Offline

How it would break the activity feed is a "special' character would show up in the BuddyPress Activity Feed. Like a diamond or strange A, � , etc. You could see it in the feed, but when you try to filter it, it would return blank due to it.

To make it work again I had to delete the item from the activity feed.

Dec 3, 2010
10:47 am
Rookie
Forum Posts: 2
Member Since:
Nov 30, 2010
Offline

I want to install Simple Press on a WP multisite with Buddypress.  My question is this – will I be able to integrate the forum into the activity stream if the forum is installed on a different site on the network than Buddypress?

 

Thank you for all your work on this, btw. 

Dec 3, 2010
10:56 am

SP Master
Forum Posts: 22240
Member Since:
Nov 9, 2008
Offline

In reality I do not have any idea… (Mr Papa is better at both Multi-site and BP questions but he is on vacation) but I am guessing the answer is likely to be no.

Yellow Swordfish
Forum Timezone: America/Chicago

Most Users Ever Online: 444

Currently Online: SPQC, joelrob
56 Guest(s)

Currently Browsing this Page:
2 Guest(s)

See All Online Activity

Top Posters:

-Radio-: 1251

Lee H: 606

Luffer: 535

Conrad_Farlow: 502

jim: 478

neon: 263

ovizii: 240

Tal: 240

Member Stats:

Guest Posters: 2626

Members: 7363

Moderators: 1

Admins: 2

Forum Stats:

Groups: 5

Forums: 16

Topics: 10898

Posts: 79583

Moderators: Brandon C (162)

Administrators: Yellow Swordfish (22240), Mr Papa (23688)