Skip to:
Content

BuddyPress.org

Changeset 2697


Ignore:
Timestamp:
02/12/2010 01:01:19 PM (16 years ago)
Author:
apeatling
Message:

Adding filters to all BuddyPress wp_mail() calls.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity/bp-activity-notifications.php

    r2663 r2697  
    4040                        $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    4141
    42                         // Send it
     42                        /* Send the message */
     43                        $to = apply_filters( 'bp_activity_at_message_notification_to', $to );
     44                        $subject = apply_filters( 'bp_activity_at_message_notification_subject', $subject );
     45                        $message = apply_filters( 'bp_activity_at_message_notification_message', $message );
     46
    4347                        wp_mail( $to, $subject, $message );
    4448                }
     
    7680                $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    7781
    78                 // Send it
     82                /* Send the message */
     83                $to = apply_filters( 'bp_activity_new_comment_notification_to', $to );
     84                $subject = apply_filters( 'bp_activity_new_comment_notification_subject', $subject );
     85                $message = apply_filters( 'bp_activity_new_comment_notification_message', $message );
     86
    7987                wp_mail( $to, $subject, $message );
    8088        }
     
    111119                $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    112120
    113                 // Send it
     121                /* Send the message */
     122                $to = apply_filters( 'bp_activity_new_comment_notification_comment_author_to', $to );
     123                $subject = apply_filters( 'bp_activity_new_comment_notification_comment_author_subject', $subject );
     124                $message = apply_filters( 'bp_activity_new_comment_notification_comment_author_message', $message );
     125
    114126                wp_mail( $to, $subject, $message );
    115127        }
  • trunk/bp-core/bp-core-activation.php

    r2635 r2697  
    114114        $subject = '[' . $from_name . '] ' . sprintf(__('Activate %s', 'buddypress' ), clean_url('http://' . $domain . $path));
    115115
    116         wp_mail( $user_email, $subject, $message, $message_headers );
     116        /* Send the message */
     117        $to = apply_filters( 'bp_core_activation_signup_blog_notification_to', $user_email );
     118        $subject = apply_filters( 'bp_core_activation_signup_blog_notification_subject', $subject );
     119        $message = apply_filters( 'bp_core_activation_signup_blog_notification_message', $message );
     120
     121        wp_mail( $to, $subject, $message, $message_headers );
    117122
    118123        // Return false to stop the original WPMU function from continuing
     
    141146        $subject = '[' . $from_name . '] ' . __( 'Activate Your Account', 'buddypress' );
    142147
    143         wp_mail( $user_email, $subject, $message, $message_headers );
     148        /* Send the message */
     149        $to = apply_filters( 'bp_core_activation_signup_user_notification_to', $user_email );
     150        $subject = apply_filters( 'bp_core_activation_signup_user_notification_subject', $subject );
     151        $message = apply_filters( 'bp_core_activation_signup_user_notification_message', $message );
     152
     153        wp_mail( $to, $subject, $message, $message_headers );
    144154
    145155        // Return false to stop the original WPMU function from continuing
  • trunk/bp-friends/bp-friends-notifications.php

    r2307 r2697  
    3333        $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    3434
    35         // Send it
     35        /* Send the message */
     36        $to = apply_filters( 'friends_notification_new_request_to', $to );
     37        $subject = apply_filters( 'friends_notification_new_request_subject', $subject );
     38        $message = apply_filters( 'friends_notification_new_request_message', $message );
     39
    3640        wp_mail( $to, $subject, $message );
    3741}
    38 
    3942
    4043function friends_notification_accepted_request( $friendship_id, $initiator_id, $friend_id ) {
     
    6770        $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    6871
    69         // Send it
     72        /* Send the message */
     73        $to = apply_filters( 'friends_notification_accepted_request_to', $to );
     74        $subject = apply_filters( 'friends_notification_accepted_request_subject', $subject );
     75        $message = apply_filters( 'friends_notification_accepted_request_message', $message );
     76
    7077        wp_mail( $to, $subject, $message );
    7178}
    7279
    73 
    7480?>
  • trunk/bp-groups/bp-groups-notifications.php

    r2663 r2697  
    2929                $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    3030
    31                 // Send it
     31                /* Send the message */
     32                $to = apply_filters( 'groups_notification_group_updated_to', $to );
     33                $subject = apply_filters( 'groups_notification_group_updated_subject', $subject );
     34                $message = apply_filters( 'groups_notification_group_updated_message', $message );
     35
    3236                wp_mail( $to, $subject, $message );
    3337
     
    7377        $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    7478
    75         // Send it
     79        /* Send the message */
     80        $to = apply_filters( 'groups_notification_new_membership_request_to', $to );
     81        $subject = apply_filters( 'groups_notification_new_membership_request_subject', $subject );
     82        $message = apply_filters( 'groups_notification_new_membership_request_message', $message );
     83
    7684        wp_mail( $to, $subject, $message );
    7785}
     
    122130        $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    123131
    124         // Send it
     132        /* Send the message */
     133        $to = apply_filters( 'groups_notification_membership_request_completed_to', $to );
     134        $subject = apply_filters( 'groups_notification_membership_request_completed_subject', $subject );
     135        $message = apply_filters( 'groups_notification_membership_request_completed_message', $message );
     136
    125137        wp_mail( $to, $subject, $message );
    126138}
     
    164176        $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    165177
    166         // Send it
     178        /* Send the message */
     179        $to = apply_filters( 'groups_notification_promoted_member_to', $to );
     180        $subject = apply_filters( 'groups_notification_promoted_member_subject', $subject );
     181        $message = apply_filters( 'groups_notification_promoted_member_message', $message );
     182
    167183        wp_mail( $to, $subject, $message );
    168184}
     
    212228                $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    213229
    214                 // Send it
     230                /* Send the message */
     231                $to = apply_filters( 'groups_notification_group_invites_to', $to );
     232                $subject = apply_filters( 'groups_notification_group_invites_subject', $subject );
     233                $message = apply_filters( 'groups_notification_group_invites_message', $message );
     234
    215235                wp_mail( $to, $subject, $message );
    216236        }
     
    262282                        $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    263283
    264                         // Send it
     284                        /* Send the message */
     285                        $to = apply_filters( 'groups_at_message_notification_to', $to );
     286                        $subject = apply_filters( 'groups_at_message_notification_subject', $subject );
     287                        $message = apply_filters( 'groups_at_message_notification_message', $message );
     288
    265289                        wp_mail( $to, $subject, $message );
    266290                }
  • trunk/bp-messages/bp-messages-notifications.php

    r2651 r2697  
    1515
    1616                // Set up and send the message
    17                 $to = $ud->user_email;
     17                $email_to = $ud->user_email;
    1818                $email_subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'New message from %s', 'buddypress' ), stripslashes( $sender_name ) );
    1919
     
    3232                $content .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    3333
    34                 // Send it
    35                 wp_mail( $to, $email_subject, $email_content );
     34                /* Send the message */
     35                $email_to = apply_filters( 'messages_notification_new_message_to', $email_to );
     36                $email_subject = apply_filters( 'messages_notification_new_message_subject', $email_subject );
     37                $email_content = apply_filters( 'messages_notification_new_message_message', $email_content );
     38
     39                wp_mail( $email_to, $email_subject, $email_content );
    3640        }
    3741}
    3842
    39 /* This is too expensive to send on normal servers uncomment action at your own risk. */
    40 function messages_notification_new_notice( $message_subject, $message ) {
    41         global $bp, $wpdb;
    42 
    43         $status_sql = bp_core_get_status_sql( 'u.' );
    44         $users = $wpdb->get_results( $wpdb->prepare( "SELECT ID as user_id, user_email, user_login FROM {$wpdb->base_prefix}users WHERE {$status_sql}" ) );
    45 
    46         for ( $i = 0; $i < count($users); $i++ ) {
    47                 if ( get_usermeta( $users[$i]->user_id, 'notification_messages_new_notice' ) == 'no' ) continue;
    48 
    49                 $message_link = bp_core_get_user_domain( $users[$i]->user_id ) . 'messages';
    50                 $settings_link = bp_core_get_user_domain( $users[$i]->user_id ) . 'settings/notifications';
    51 
    52                 // Set up and send the message
    53                 $to = $users[$i]->user_email;
    54                 $subject = __( 'New Site Notice', 'buddypress' );
    55 
    56                 $message = sprintf( __(
    57 'A new site notice has been posted on %s:
    58 
    59 "%s: %s"
    60 
    61 To view the notice: %s
    62 
    63 ---------------------
    64 ', 'buddypress' ), get_blog_option( BP_ROOT_BLOG, 'blogname' ), stripslashes( wp_filter_kses( $message_subject ) ), stripslashes( wp_filter_kses( $message ) ), $message_link );
    65 
    66                 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    67 
    68                 // Send it
    69                 wp_mail( $to, $subject, $message );
    70 
    71                 unset($message);
    72                 unset($subject);
    73                 unset($to);
    74         }
    75 }
    76 // add_action( 'bp_messages_notice_sent', 'messages_notification_new_notice', 10, 2 );
    77 
    7843?>
Note: See TracChangeset for help on using the changeset viewer.