Skip to:
Content

BuddyPress.org


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

Adding filters to all BuddyPress wp_mail() calls.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.