Advertisement
Guest User

bp_custom.php

a guest
Mar 2nd, 2021
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. `<?php
  2.  
  3. //function buddydev_mail_on_new_group_activity( $user_ids, $args ) {
  4.  
  5. if ( empty($user_ids ) ) {
  6. return ;
  7. }
  8. //do a bulk query
  9. $users = get_users( array( 'include' => $user_ids ) );
  10.  
  11. $group = new BP_Groups_Group( $args['group_id'] );
  12. $loggedin_user_display_name = bp_get_loggedin_user_fullname();
  13.  
  14. $activity = new BP_Activity_Activity( $args['activity_id'] );
  15.  
  16. $activity_content = $activity->content;
  17. $activity_permalink = bp_activity_get_permalink( $activity->id, $activity );
  18.  
  19. $subject = sprintf( '%1$s posted to %2$s', $loggedin_user_display_name, $group->name );
  20. $message = <<<'MAINCONTENT'
  21. Hi %1$s,
  22. %2$s posted...
  23.  
  24. %3$s
  25.  
  26. Link: %4$s
  27. MAINCONTENT;
  28.  
  29. foreach ( $users as $user ) {
  30. $message = sprintf( $message, $user->displayname, $loggedin_user_display_name, $activity_content, $activity_permalink );
  31. wp_mail( $user->user_email, $subject, $message );
  32. }
  33. }
  34. add_action( 'bp_group_activities_notify_members', 'buddydev_mail_on_new_group_activity', 10, 2 );
  35. }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement