Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: activity streams example

Gah, as you can tell, not an easy thing to answer. You can really figure it out from the custom component template plugin.

You need the following in your setup_globals:

$bp->achievements->format_activity_function = 'dpa_format_activity';

and this function

<br />
function dpa_format_activity( $item_id, $user_id, $action, $secondary_item_id = false, $for_secondary_user = false ) {<br />
global $bp;</p>
<p> switch( $action ) {<br />
case 'new_achievement':<br />
$user_link = bp_core_get_userlink( $user_id );<br />
$achievement_name = apply_filters( 'dpa_filter_achievement_nice_name', dpa_get( 'nice_name', array( array( 'type' => 'd', 'key' => 'id', 'value' => $item_id ) ), 1 ) );</p>
<p> return array(<br />
'primary_link' => $user_link,<br />
'content' => apply_filters( 'dpa_new_achievement_activity', sprintf( __( '%s unlocked achievement: %s', 'dpa-achievement' ), $user_link, $achievement_name ) . __( ' <span class="time-since">%s</span>', 'dpa-achievement' ), $user_id, $item_id )<br />
);<br />
break;<br />
}</p>
<p> do_action( 'dpa_format_activity', $action, $item_id, $user_id, $action, $secondary_item_id, $for_secondary_user );</p>
<p> return false;<br />
}<br />

And to record activity:

<br />
dpa_record_activity(<br />
array(<br />
'item_id' => $achievement_id,<br />
'user_id' => $this->user_id,<br />
'component_name' => $bp->achievements->slug,<br />
'component_action' => 'new_achievement',<br />
'is_private' => 0<br />
)<br />
);<br />

Skip to toolbar