Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter( 'mycred_add', 'mycred_to_bp_activity', 999, 3 );
- function mycred_to_bp_activity( $reply, $request, $mycred ) {
- // Only applicable if the points have not been declined and if BP is installed
- if ( $reply === false || ! function_exists( 'bp_activity_add' ) ) return $reply;
- extract( $request );
- // Construct a log entry so we can use $mycred->parse_template_tags()
- $log_entry = new stdClass();
- $log_entry->ref = $ref;
- $log_entry->user_id = (int) $user_id;
- $log_entry->creds = $mycred->number( $amount );
- $log_entry->ref_id = $ref_id;
- $log_entry->entry = $entry;
- $log_entry->data = $data;
- $log_entry->ctype = $type;
- // Add entry
- bp_activity_add( array(
- 'user_id' => (int) $user_id,
- 'type' => 'mycred',
- 'component' => 'activity',
- 'primary_link' => bp_core_get_userlink( (int) $user_id, false, true ),
- 'content' => $mycred->parse_template_tags( $entry, $log_entry ),
- 'hide_sitewide' => false
- ) );
- // As a filter we must always return something
- return $reply;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement