bp_core_deprecated_email_actions

Add support for pre-2.5 email actions.

Description

bp_core_deprecated_email_actions( (bool|WP_Error) $delivery_status, (BP_Email) $email ); 

Parameters (2)

0. $delivery_status (bool|WP_Error)
Bool if the email was sent or not. If a WP_Error, there was a failure.
1. $email (BP_Email)
Email object reference.

Usage

  1. if ( !function_exists( 'bp_core_deprecated_email_actions' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-core/deprecated/2.5.php'; 
  3.  
  4. // Bool if the email was sent or not. 
  5. // If a WP_Error, there was a failure. 
  6. $delivery_status = null; 
  7.  
  8. // Email object reference. 
  9. $email = null; 
  10.  
  11. // NOTICE! Understand what this does before running. 
  12. $result = bp_core_deprecated_email_actions($delivery_status, $email); 
  13.  

Defined (1)

The function is defined in the following location(s).

/bp-core/deprecated/2.5.php  
  1. function bp_core_deprecated_email_actions( $delivery_status, $email ) { 
  2. $pre_2_5_emails = array( 
  3. 'activity-comment',  
  4. 'activity-comment-author',  
  5. 'core-user-registration',  
  6. 'core-user-registration-with-blog',  
  7. 'friends-request',  
  8. 'friends-request-accepted',  
  9. 'groups-details-updated',  
  10. 'groups-invitation',  
  11. 'groups-member-promoted',  
  12. 'groups-membership-request',  
  13. 'groups-membership-request-accepted',  
  14. 'groups-membership-request-rejected',  
  15. 'messages-unread',  
  16. 'settings-verify-email-change',  
  17. ); 
  18.  
  19. remove_action( 'bp_send_email_success', 'bp_core_deprecated_email_actions', 20 ); 
  20. $email_content = $email->get( 'content' ); 
  21. $email_subject = $email->get( 'subject' ); 
  22. $email_type = $email->get( 'type' ); 
  23. $tokens = $email->get( 'tokens' ); 
  24. add_action( 'bp_send_email_success', 'bp_core_deprecated_email_actions', 20, 2 ); 
  25.  
  26. // Backpat for pre-2.5 emails only. 
  27. if ( ! in_array( $email_type, $pre_2_5_emails, true ) ) { 
  28. return; 
  29.  
  30. if ( $email_type === 'activity-comment' ) { 
  31. /** 
  32. * Fires after the sending of a reply to an update email notification. 
  33. * @since 1.5.0 
  34. * @deprecated 2.5.0 Use the filters in BP_Email. $params argument unset and deprecated. 
  35. * @param int $user_id ID of the original activity item author. 
  36. * @param string $email_subject Email notification subject text. 
  37. * @param string $email_content Email notification message text. 
  38. * @param int $comment_id ID for the newly received comment. 
  39. * @param int $commenter_id ID of the user who made the comment. 
  40. * @param array $deprecated Removed in 2.5; now an empty array. 
  41. */ 
  42. do_action( 'bp_activity_sent_reply_to_update_email', $tokens['original_activity.user_id'], $email_subject, $email_content, $tokens['comment.id'], $tokens['commenter.id'], array() ); 
  43.  
  44. } elseif ( $email_type === 'activity-comment-author' ) { 
  45. /** 
  46. * Fires after the sending of a reply to a reply email notification. 
  47. * @since 1.5.0 
  48. * @deprecated 2.5.0 Use the filters in BP_Email. $params argument unset and deprecated. 
  49. * @param int $user_id ID of the parent activity item author. 
  50. * @param string $email_subject Email notification subject text. 
  51. * @param string $email_content Email notification message text. 
  52. * @param int $comment_id ID for the newly received comment. 
  53. * @param int $commenter_id ID of the user who made the comment. 
  54. * @param array $deprecated Removed in 2.5; now an empty array. 
  55. */ 
  56. do_action( 'bp_activity_sent_reply_to_reply_email', $tokens['parent-comment-user.id'], $email_subject, $email_content, $tokens['comment.id'], $tokens['commenter.id'], array() ); 
  57.  
  58. } elseif ( $email_type === 'core-user-registration' ) { 
  59. if ( ! empty( $tokens['user.id'] ) ) { 
  60. /** 
  61. * Fires after the sending of activation email to a newly registered user. 
  62. * @since 1.5.0 
  63. * @param string $email_subject Subject for the sent email. 
  64. * @param string $email_content Message for the sent email. 
  65. * @param int $user_id ID of the new user. 
  66. * @param string $recipient_email Email address of the new user. 
  67. * @param string $key Activation key. 
  68. */ 
  69. do_action( 'bp_core_sent_user_validation_email', $email_subject, $email_content, $tokens['user.id'], $tokens['recipient.email'], $tokens['key'] ); 
  70.  
  71. } else { 
  72. /** 
  73. * Fires after the sending of the notification to new users for successful registration without blog. 
  74. * @since 1.5.0 
  75. * @deprecated 2.5.0 Use the filters in BP_Email. $meta argument unset and deprecated. 
  76. * @param string $admin_email Admin Email address for the site. 
  77. * @param string $email_subject Subject used in the notification email. 
  78. * @param string $email_content Message used in the notification email. 
  79. * @param string $recipient_username The user's login name. 
  80. * @param string $recipient_email The user's email address. 
  81. * @param string $key The activation key created in wpmu_signup_blog(). 
  82. * @param array $meta Removed in 2.5; now an empty array. 
  83. */ 
  84. do_action( 'bp_core_sent_user_signup_email', bp_get_option( 'admin_email' ), $email_subject, $email_content, $tokens['recipient.username'], $tokens['recipient.email'], $tokens['key'], array() ); 
  85.  
  86. } elseif ( $email_type === 'core-user-registration-with-blog' ) { 
  87. /** 
  88. * Fires after the sending of the notification to new users for successful registration with blog. 
  89. * @since 1.5.0 
  90. * @deprecated 2.5.0 Use the filters in BP_Email. $meta argument unset and deprecated. 
  91. * @param string $admin_email Admin Email address for the site. 
  92. * @param string $email_subject Subject used in the notification email. 
  93. * @param string $email_content Message used in the notification email. 
  94. * @param string $domain The new blog domain. 
  95. * @param string $path The new blog path. 
  96. * @param string $title The site title. 
  97. * @param string $recipient_username The user's login name. 
  98. * @param string $recipient_email The user's email address. 
  99. * @param string $key The activation key created in wpmu_signup_blog(). 
  100. * @param array $meta Removed in 2.5; now an empty array. 
  101. */ 
  102. do_action( 'bp_core_sent_blog_signup_email', bp_get_option( 'admin_email' ), $email_subject, $email_content, $tokens['domain'], $tokens['path'], $tokens['title'], $tokens['recipient.username'], $tokens['recipient.email'], $tokens['key_blog'], array() ); 
  103.  
  104. } elseif ( $email_type === 'friends-request' ) { 
  105. /** 
  106. * Fires after the new friend request email is sent. 
  107. * @since 1.5.0 
  108. * @deprecated 2.5.0 Use the filters in BP_Email. 
  109. * @param int $friend_id ID of the request recipient. 
  110. * @param string $email_subject Text for the friend request subject field. 
  111. * @param string $email_content Text for the friend request message field. 
  112. * @param int $friendship_id ID of the friendship object. 
  113. * @param int $initiator_id ID of the friendship requester. 
  114. */ 
  115. do_action( 'bp_friends_sent_request_email', $tokens['friend.id'], $email_subject, $email_content, $tokens['friendship.id'], $tokens['initiator.id'] ); 
  116.  
  117. } elseif ( $email_type === 'friends-request-accepted' ) { 
  118. /** 
  119. * Fires after the friend request accepted email is sent. 
  120. * @since 1.5.0 
  121. * @deprecated 2.5.0 Use the filters in BP_Email. 
  122. * @param int $initiator_id ID of the friendship requester. 
  123. * @param string $email_subject Text for the friend request subject field. 
  124. * @param string $email_content Text for the friend request message field. 
  125. * @param int $friendship_id ID of the friendship object. 
  126. * @param int $friend_id ID of the request recipient. 
  127. */ 
  128. do_action( 'bp_friends_sent_accepted_email', $tokens['initiator.id'], $email_subject, $email_content, $tokens['friendship.id'], $tokens['friend.id'] ); 
  129.  
  130. } elseif ( $email_type === 'groups-invitation' ) { 
  131. /** 
  132. * Fires after the notification is sent that a member has been invited to a group. 
  133. * @since 1.5.0 
  134. * @deprecated 2.5.0 Use the filters in BP_Email. 
  135. * @param int $invited_user_id ID of the user who was invited. 
  136. * @param string $email_subject Email notification subject text. 
  137. * @param string $email_content Email notification message text. 
  138. * @param BP_Groups_Group $group Group object. 
  139. */ 
  140. do_action( 'bp_groups_sent_invited_email', $tokens['inviter.id'], $email_subject, $email_content, $tokens['group'] ); 
  141.  
  142. } elseif ( $email_type === 'groups-member-promoted' ) { 
  143. /** 
  144. * Fires after the notification is sent that a member has been promoted. 
  145. * @since 1.5.0 
  146. * @deprecated 2.5.0 Use the filters in BP_Email. 
  147. * @param int $user_id ID of the user who was promoted. 
  148. * @param string $email_subject Email notification subject text. 
  149. * @param string $email_content Email notification message text. 
  150. * @param int $group_id ID of the group that the user is a member of. 
  151. */ 
  152. do_action( 'bp_groups_sent_promoted_email', $tokens['user.id'], $email_subject, $email_content, $tokens['group.id'] ); 
  153.  
  154. } elseif ( $email_type === 'groups-membership-request' ) { 
  155. /** 
  156. * Fires after the notification is sent that a member has requested group membership. 
  157. * @since 1.5.0 
  158. * @deprecated 2.5.0 Use the filters in BP_Email. 
  159. * @param int $admin_id ID of the group administrator. 
  160. * @param string $email_subject Email notification subject text. 
  161. * @param string $email_content Email notification message text. 
  162. * @param int $requesting_user_id ID of the user requesting membership. 
  163. * @param int $group_id ID of the group receiving membership request. 
  164. * @param int $membership_id ID of the group membership object. 
  165. */ 
  166. do_action( 'bp_groups_sent_membership_request_email', $tokens['admin.id'], $email_subject, $email_content, $tokens['requesting-user.id'], $tokens['group.id'], $tokens['membership.id'] ); 
  167.  
  168. } elseif ( $email_type === 'groups-membership-request-accepted' || $email_type === 'groups-membership-request-rejected' ) { 
  169. /** 
  170. * Fires after the notification is sent that a membership has been approved. 
  171. * @since 1.5.0 
  172. * @deprecated 2.5.0 Use the filters in BP_Email. 
  173. * @param int $requesting_user_id ID of the user whose membership was approved. 
  174. * @param string $email_subject Email notification subject text. 
  175. * @param string $email_content Email notification message text. 
  176. * @param int $group_id ID of the group that was joined. 
  177. */ 
  178. do_action( 'bp_groups_sent_membership_approved_email', $tokens['requesting-user.id'], $email_subject, $email_content, $tokens['group.id'] );