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
Jun 1, 2010
1:10 pm
Member
Forum Posts: 27
Member Since:
Feb 3, 2009
Offline

I am working with the sf_hook_post_save hook to integrate with the BP activity stream.

The bit I am stuck on is getting the new topic/post's title. There is a "topic sub" but that returns nothing and not sure what it actually is. I am using topic_slug currently but would like to use the actual title.

Any thoughts?

Visit the Twitter Poker Tour Forum to see my Simple-Press implementation

Jun 1, 2010
5:18 pm

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

Should find it in $newpost['topicname']

Yellow Swordfish
Jun 1, 2010
8:22 pm
Member
Forum Posts: 27
Member Since:
Feb 3, 2009
Offline

Yellow Swordfish said:

Should find it in $newpost['topicname']

That didn't seem to work. Are you sure it's part of the array for the sf_hook_post_save function? Here is the array printed for a post I just made:

 

Array (
[forumid] => 15
[forumslug] => live-and-online-major-events
[topicid] => 218
[topicslug] => last-week-to-satellite-to-step3-2k-wsop-package
[postid] => 1360
[submsg] =>
[postpin] => 0
[topiclock] => 0
[topicsub] =>
[topicwatch] =>
[topicsubend] =>
[topicwatchend] =>
[statvalue] =>
[posttimestamp] => '2010-06-01 21:13:46'
[poststatus] => 0
[postcontent] => Annnnd....Late Reg has ended, we picked up two more players. We will easily get two players registered for STEP2 tonight!
[guestname] =>
[guestemail] =>
[postername] => cprpoker
[posteremail] => cprpoker@domain.com
[userid] => 999
[ip] => xx.xx.xx.xx
[db] => 1
[url] => http://domain.com/forum/blah-b.....lah/#p1360
)

Is there a function I can use to get the Topic Name by topicID?

Thanks!

Visit the Twitter Poker Tour Forum to see my Simple-Press implementation

Jun 1, 2010
8:28 pm

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

sorry, on droid and havent read this topoic, but to answer your last question:

sf_get_topic_name_from_id($topicid)

will return the topic name based on id…

Jun 1, 2010
8:34 pm
Member
Forum Posts: 27
Member Since:
Feb 3, 2009
Offline

Mr Papa said:

sorry, on droid and havent read this topoic, but to answer your last question:

sf_get_topic_name_from_id($topicid)

will return the topic name based on id…


Bingo.

 

Thanks!!

Visit the Twitter Poker Tour Forum to see my Simple-Press implementation

Jun 1, 2010
10:21 pm

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

any thoughts of sharing this when you are done for the other BP users?

Jun 2, 2010
11:10 am
Member
Forum Posts: 27
Member Since:
Feb 3, 2009
Offline

Oh, absolutely, here it is. It's still very rough for now, so use at your own peril Cool. I'll try to keep this post updated with any major changes.

 

	function sf_hook_post_save($newpost, $action)
	{
		global $bp;
		$activity = new BP_Activity_Activity();
		$date_recorded = date('Y-m-d H:i:s', strtotime('+4 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 = "sf_post";
		$activity->action = ''.$user_fullname.'' . $the_action . '' . $topic_title . ':';
		$activity->content = $mycontent;
		$activity->primary_link = "";
		$activity->secondary_item_id = "";
		$activity->date_recorded = $date_recorded;
		$activity->hide_sitewide = 0;
		$activity->save ();
	
		return;
	}

Visit the Twitter Poker Tour Forum to see my Simple-Press implementation

Jun 2, 2010
12:58 pm

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

thanks! think this will be used by others!  just wait for 5.0 when you can make this a plugin for simple:press!

Jun 3, 2010
2:58 pm
Member
Forum Posts: 103
Member Since:
May 8, 2010
Offline

Excellent feature!

Be a really good feature in integrating SPF with BP and WP3 … this option should be standard and availble in forum configuration backend ^^

 

Can anyone give apointer to where do i implement this code path/file.php?

Jun 4, 2010
1:29 am

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

its in the very first post… use hook sf_hook_post_save()… see our wiki if you need help on using hooks…

Forum Timezone: America/Chicago

Most Users Ever Online: 444

Currently Online: steve.engelking, irlandes1
49 Guest(s)

Currently Browsing this Page:
1 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)