Advertisement
designbymerovingi

UserPro Activity for myCRED

Mar 16th, 2015
429
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. /**
  2. * Add UserPro Activity
  3. * Adds a new activity entry for a user in UserPro when gaining / losing
  4. * points.
  5. * @version 1.0
  6. */
  7. add_filter( 'mycred_add_finished', 'mycred_pro_add_userpro_activity', 10, 3 );
  8. function mycred_pro_add_userpro_activity( $result, $request, $mycred ) {
  9.  
  10. if ( $result === false ) return $result;
  11.  
  12. extract( $request );
  13.  
  14. global $userpro;
  15.  
  16. $activity = (array) get_option( 'userpro_activity' );
  17. $timestamp = current_time( 'timestamp' );
  18.  
  19. // Construct a log entry so we can use $mycred->parse_template_tags()
  20. $log_entry = new stdClass();
  21. $log_entry->ref = $ref;
  22. $log_entry->user_id = absint( $user_id );
  23. $log_entry->creds = $mycred->number( $amount );
  24. $log_entry->ref_id = $ref_id;
  25. $log_entry->entry = $entry;
  26. $log_entry->data = $data;
  27. $log_entry->ctype = $type;
  28.  
  29. $template = $mycred->parse_template_tags( $entry, $log_entry );
  30.  
  31. $status = '<div class="userpro-sc-img" data-key="profilepicture"><a href="' . $userpro->permalink( $user_id ) . '">' . get_avatar( $user_id, '50' ) . '</a></div><div class="userpro-sc-i"><div class="userpro-sc-i-name"><a href="' . $userpro->permalink( $user_id ) . '" title="View Profile">'. userpro_profile_data( 'display_name', $user_id ) . '</a><span class="userpro-sc-i-info">' . $template . '</span></div><div class="userpro-sc-i-time">{timestamp}</div></div><div class="userpro-clear"></div>';
  32.  
  33. $activity[ $user_id ][ $timestamp ] = array(
  34. 'user_id' => $user_id,
  35. 'status' => $status,
  36. 'timestamp' => $timestamp
  37. );
  38.  
  39. update_option( 'userpro_activity', $activity );
  40.  
  41. return $result;
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement