Ticket #2162: 2162.patch
File 2162.patch, 4.1 KB (added by , 11 years ago) |
---|
-
includes/common/functions.php
1017 1017 function bbp_notify_subscribers( $reply_id = 0, $topic_id = 0, $forum_id = 0, $anonymous_data = false, $reply_author = 0 ) { 1018 1018 1019 1019 // Bail if subscriptions are turned off 1020 if ( !bbp_is_subscriptions_active() ) 1020 if ( !bbp_is_subscriptions_active() ) { 1021 1021 return false; 1022 } 1022 1023 1023 1024 /** Validation ************************************************************/ 1024 1025 … … 1029 1030 /** Reply *****************************************************************/ 1030 1031 1031 1032 // Bail if reply is not published 1032 if ( !bbp_is_reply_published( $reply_id ) ) 1033 if ( !bbp_is_reply_published( $reply_id ) ) { 1033 1034 return false; 1035 } 1034 1036 1037 // Poster name 1038 $reply_author_name = bbp_get_reply_author_display_name( $reply_id ); 1039 1035 1040 /** Topic *****************************************************************/ 1036 1041 1037 1042 // Bail if topic is not published 1038 if ( !bbp_is_topic_published( $topic_id ) ) 1043 if ( !bbp_is_topic_published( $topic_id ) ) { 1039 1044 return false; 1045 } 1040 1046 1041 /** User ******************************************************************/1042 1043 // Get topic subscribers and bail if empty1044 $user_ids = bbp_get_topic_subscribers( $topic_id, true );1045 if ( empty( $user_ids ) )1046 return false;1047 1048 // Poster name1049 $reply_author_name = bbp_get_reply_author_display_name( $reply_id );1050 1051 1047 /** Mail ******************************************************************/ 1052 1048 1053 1049 do_action( 'bbp_pre_notify_subscribers', $reply_id, $topic_id, $user_ids ); … … 1063 1059 $reply_url = bbp_get_reply_url( $reply_id ); 1064 1060 $blog_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); 1065 1061 1066 // Loop through users1067 foreach ( (array) $user_ids as $user_id ) {1068 1069 // Don't send notifications to the person who made the post1070 if ( !empty( $reply_author ) && (int) $user_id === (int) $reply_author )1071 continue;1072 1073 1062 // For plugins to filter messages per reply/topic/user 1074 1063 $message = sprintf( __( '%1$s wrote: 1075 1064 … … 1088 1077 $reply_url 1089 1078 ); 1090 1079 1091 $message = apply_filters( 'bbp_subscription_mail_message', $message, $reply_id, $topic_id, $user_id ); 1092 if ( empty( $message ) ) 1093 continue; 1080 $message = apply_filters( 'bbp_subscription_mail_message', $message, $reply_id, $topic_id ); 1081 if ( empty( $message ) ) { 1082 return; 1083 } 1094 1084 1095 1085 // For plugins to filter titles per reply/topic/user 1096 $subject = apply_filters( 'bbp_subscription_mail_title', '[' . $blog_name . '] ' . $topic_title, $reply_id, $topic_id, $user_id ); 1097 if ( empty( $subject ) ) 1086 $subject = apply_filters( 'bbp_subscription_mail_title', '[' . $blog_name . '] ' . $topic_title, $reply_id, $topic_id ); 1087 if ( empty( $subject ) ) { 1088 return; 1089 } 1090 1091 /** Users *****************************************************************/ 1092 1093 // Do not reply address 1094 $do_not_reply = 'noreply@' . get_bloginfo( 'url' ); 1095 1096 // Array to hold BCC's 1097 $headers = array(); 1098 1099 // Setup the From header 1100 $headers[] = 'From: . ' . get_bloginfo( 'name' ) . $do_not_reply; 1101 1102 // Get topic subscribers and bail if empty 1103 $user_ids = bbp_get_topic_subscribers( $topic_id, true ); 1104 if ( empty( $user_ids ) ) { 1105 return false; 1106 } 1107 1108 // Loop through users 1109 foreach ( (array) $user_ids as $user_id ) { 1110 1111 // Don't send notifications to the person who made the post 1112 if ( !empty( $reply_author ) && (int) $user_id === (int) $reply_author ) { 1098 1113 continue; 1114 } 1099 1115 1100 // Custom headers 1101 $headers = apply_filters( 'bbp_subscription_mail_headers', array() ); 1116 // Get email address of subscribed user 1117 $headers[] = 'Bcc: ' . get_userdata( $user_id )->user_email; 1118 } 1102 1119 1103 // Get user data of this user 1104 $user = get_userdata( $user_id ); 1120 /** Send it ***************************************************************/ 1105 1121 1122 // Custom headers 1123 $headers = apply_filters( 'bbp_subscription_mail_headers', $headers ); 1124 1106 1125 // Send notification email 1107 wp_mail( $user->user_email, $subject, $message, $headers ); 1108 } 1126 wp_mail( $do_not_reply, $subject, $message, $headers ); 1109 1127 1110 1128 do_action( 'bbp_post_notify_subscribers', $reply_id, $topic_id, $user_ids ); 1111 1129