diff --git src/includes/common/functions.php src/includes/common/functions.php
index da33568..0c89a45 100644
|
|
function bbp_notify_topic_subscribers( $reply_id = 0, $topic_id = 0, $forum_id = |
1101 | 1101 | // Poster name |
1102 | 1102 | $reply_author_name = bbp_get_reply_author_display_name( $reply_id ); |
1103 | 1103 | |
| 1104 | /** Users *****************************************************************/ |
| 1105 | |
| 1106 | // Get topic subscribers and bail if empty |
| 1107 | $user_ids = bbp_get_topic_subscribers( $topic_id, true ); |
| 1108 | |
| 1109 | // Dedicated filter to manipulate user ID's to send emails to |
| 1110 | $user_ids = (array) apply_filters( 'bbp_topic_subscription_user_ids', $user_ids ); |
| 1111 | $user_ids = array_filter( array_map( 'intval', $user_ids ) ); |
| 1112 | if ( empty( $user_ids ) ) { |
| 1113 | return false; |
| 1114 | } |
| 1115 | |
| 1116 | // Remove the reply author from the list. |
| 1117 | $reply_author_key = array_search( (int) $reply_author, $user_ids, true ); |
| 1118 | if ( false !== $reply_author_key ) { |
| 1119 | unset( $user_ids[ $reply_author_key ] ); |
| 1120 | } |
| 1121 | |
| 1122 | // Bail of the reply author was the only one subscribed. |
| 1123 | if ( empty( $user_ids ) ) { |
| 1124 | return false; |
| 1125 | } |
| 1126 | |
1104 | 1127 | /** Mail ******************************************************************/ |
1105 | 1128 | |
1106 | 1129 | // Remove filters from reply content and topic title to prevent content |
… |
… |
Login and visit the topic to unsubscribe from these emails.', 'bbpress' ), |
1143 | 1166 | return; |
1144 | 1167 | } |
1145 | 1168 | |
1146 | | /** Users *****************************************************************/ |
| 1169 | /** Headers ***************************************************************/ |
1147 | 1170 | |
1148 | 1171 | // Get the noreply@ address |
1149 | 1172 | $no_reply = bbp_get_do_not_reply_address(); |
… |
… |
Login and visit the topic to unsubscribe from these emails.', 'bbpress' ), |
1154 | 1177 | // Setup the From header |
1155 | 1178 | $headers = array( 'From: ' . get_bloginfo( 'name' ) . ' <' . $from_email . '>' ); |
1156 | 1179 | |
1157 | | // Get topic subscribers and bail if empty |
1158 | | $user_ids = bbp_get_topic_subscribers( $topic_id, true ); |
1159 | | |
1160 | | // Dedicated filter to manipulate user ID's to send emails to |
1161 | | $user_ids = apply_filters( 'bbp_topic_subscription_user_ids', $user_ids ); |
1162 | | if ( empty( $user_ids ) ) { |
1163 | | return false; |
1164 | | } |
1165 | | |
1166 | 1180 | // Loop through users |
1167 | 1181 | foreach ( (array) $user_ids as $user_id ) { |
1168 | 1182 | |
1169 | | // Don't send notifications to the person who made the post |
1170 | | if ( ! empty( $reply_author ) && (int) $user_id === (int) $reply_author ) { |
1171 | | continue; |
1172 | | } |
1173 | | |
1174 | 1183 | // Get email address of subscribed user |
1175 | 1184 | $headers[] = 'Bcc: ' . get_userdata( $user_id )->user_email; |
1176 | 1185 | } |
… |
… |
function bbp_notify_forum_subscribers( $topic_id = 0, $forum_id = 0, $anonymous_ |
1258 | 1267 | // Poster name |
1259 | 1268 | $topic_author_name = bbp_get_topic_author_display_name( $topic_id ); |
1260 | 1269 | |
| 1270 | /** Users *****************************************************************/ |
| 1271 | |
| 1272 | // Get topic subscribers and bail if empty |
| 1273 | $user_ids = bbp_get_forum_subscribers( $forum_id, true ); |
| 1274 | |
| 1275 | // Dedicated filter to manipulate user ID's to send emails to |
| 1276 | $user_ids = (array) apply_filters( 'bbp_forum_subscription_user_ids', $user_ids ); |
| 1277 | $user_ids = array_filter( array_map( 'intval', $user_ids ) ); |
| 1278 | if ( empty( $user_ids ) ) { |
| 1279 | return false; |
| 1280 | } |
| 1281 | |
| 1282 | // Remove the topic author from the list. |
| 1283 | $topic_author_key = array_search( (int) $topic_author, $user_ids, true ); |
| 1284 | if ( false !== $topic_author_key ) { |
| 1285 | unset( $user_ids[ $topic_author_key ] ); |
| 1286 | } |
| 1287 | |
| 1288 | // Bail of the topic author was the only one subscribed. |
| 1289 | if ( empty( $user_ids ) ) { |
| 1290 | return false; |
| 1291 | } |
| 1292 | |
1261 | 1293 | /** Mail ******************************************************************/ |
1262 | 1294 | |
1263 | 1295 | // Remove filters from reply content and topic title to prevent content |
… |
… |
Login and visit the topic to unsubscribe from these emails.', 'bbpress' ), |
1300 | 1332 | return; |
1301 | 1333 | } |
1302 | 1334 | |
1303 | | /** User ******************************************************************/ |
| 1335 | /** Headers ***************************************************************/ |
1304 | 1336 | |
1305 | 1337 | // Get the noreply@ address |
1306 | 1338 | $no_reply = bbp_get_do_not_reply_address(); |
… |
… |
Login and visit the topic to unsubscribe from these emails.', 'bbpress' ), |
1311 | 1343 | // Setup the From header |
1312 | 1344 | $headers = array( 'From: ' . get_bloginfo( 'name' ) . ' <' . $from_email . '>' ); |
1313 | 1345 | |
1314 | | // Get topic subscribers and bail if empty |
1315 | | $user_ids = bbp_get_forum_subscribers( $forum_id, true ); |
1316 | | |
1317 | | // Dedicated filter to manipulate user ID's to send emails to |
1318 | | $user_ids = apply_filters( 'bbp_forum_subscription_user_ids', $user_ids ); |
1319 | | if ( empty( $user_ids ) ) { |
1320 | | return false; |
1321 | | } |
1322 | | |
1323 | 1346 | // Loop through users |
1324 | 1347 | foreach ( (array) $user_ids as $user_id ) { |
1325 | 1348 | |
1326 | | // Don't send notifications to the person who made the post |
1327 | | if ( ! empty( $topic_author ) && (int) $user_id === (int) $topic_author ) { |
1328 | | continue; |
1329 | | } |
1330 | | |
1331 | 1349 | // Get email address of subscribed user |
1332 | 1350 | $headers[] = 'Bcc: ' . get_userdata( $user_id )->user_email; |
1333 | 1351 | } |