Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/27/2016 09:15:07 PM (10 years ago)
Author:
djpaul
Message:

Emails: refactor notification functions and use bp_send_email to send email.

Backwards compatibility is mostly maintained, though there are a few unavoidable instances where some data passed to filters is no longer sent (an empty string or equivalent is provided to avoid PHP Notices). These will be detailed in a post on bpdevel.wordpress.com in the feature to alert plugin developers.

See #6592. Props timersys, mercime, boonebgorges, hnla, DJPaul.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-groups/bp-groups-notifications.php

    r10417 r10479  
    2525 */
    2626function groups_notification_group_updated( $group_id = 0, $old_group = null ) {
    27 
    2827    $group = groups_get_group( array( 'group_id' => $group_id ) );
    2928
     
    3332        if ( $group->name !== $old_group->name ) {
    3433            $changed[] = sprintf(
    35                 _x( '* Name changed from "%s" to "%s"', 'Group update email text', 'buddypress' ),
     34                _x( '* Name changed from "%s" to "%s".', 'Group update email text', 'buddypress' ),
    3635                esc_html( $old_group->name ),
    3736                esc_html( $group->name )
     
    4140        if ( $group->description !== $old_group->description ) {
    4241            $changed[] = sprintf(
    43                 _x( '* Description changed from "%s" to "%s"', 'Group update email text', 'buddypress' ),
     42                _x( '* Description changed from "%s" to "%s".', 'Group update email text', 'buddypress' ),
    4443                esc_html( $old_group->description ),
    4544                esc_html( $group->description )
     
    5958    $changed_text = '';
    6059    if ( ! empty( $changed ) ) {
    61         $changed_text = "\n\n" . implode( "\n", $changed );
    62     }
    63 
    64     $subject  = bp_get_email_subject( array( 'text' => __( 'Group Details Updated', 'buddypress' ) ) );
     60        $changed_text = implode( "\n", $changed );
     61    }
     62
    6563    $user_ids = BP_Groups_Member::get_group_member_ids( $group->id );
    66 
    6764    foreach ( (array) $user_ids as $user_id ) {
    6865
     
    7269        }
    7370
    74         $ud = bp_core_get_core_userdata( $user_id );
    75 
    76         // Set up and send the message.
    77         $to = $ud->user_email;
    78 
    79         $group_link    = bp_get_group_permalink( $group );
    80         $settings_slug = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings';
    81         $settings_link = bp_core_get_user_domain( $user_id ) . $settings_slug . '/notifications/';
    82 
    83         $message = sprintf( __(
    84 'Group details for the group "%1$s" were updated: %2$s
    85 
    86 To view the group: %3$s
    87 
    88 ---------------------
    89 ', 'buddypress' ), $group->name, $changed_text, $group_link );
    90 
    91         $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    92 
    93         /**
    94          * Filters the user email that the group update notification will be sent to.
    95          *
    96          * @since 1.2.0
    97          *
    98          * @param string $to User email the notification is being sent to.
    99          */
    100         $to      = apply_filters( 'groups_notification_group_updated_to', $to );
    101 
    102         /**
    103          * Filters the group update notification subject that will be sent to user.
    104          *
    105          * @since 1.2.0
    106          *
    107          * @param string          $subject Email notification subject text.
    108          * @param BP_Groups_Group $group   Object holding the current group instance. Passed by reference.
    109          */
    110         $subject = apply_filters_ref_array( 'groups_notification_group_updated_subject', array( $subject, &$group ) );
    111 
    112         /**
    113          * Filters the group update notification message that will be sent to user.
    114          *
    115          * @since 1.2.0
    116          *
    117          * @param string          $message       Email notification message text.
    118          * @param BP_Groups_Group $group         Object holding the current group instance. Passed by reference.
    119          * @param string          $group_link    URL permalink to the group that was updated.
    120          * @param string          $settings_link URL permalink for the user's notification settings area.
    121          */
    122         $message = apply_filters_ref_array( 'groups_notification_group_updated_message', array( $message, &$group, $group_link, $settings_link ) );
    123 
    124         wp_mail( $to, $subject, $message );
    125 
    126         unset( $message, $to );
     71        $args = array(
     72            'tokens' => array(
     73                'changed_text' => $changed_text,
     74                'group'        => $group,
     75                'group.id'     => $group_id,
     76                'group.url'    => esc_url( bp_get_group_permalink( $group ) ),
     77                'group.name'   => $group->name,
     78            ),
     79        );
     80        bp_send_email( 'groups-details-updated', $user_id, $args );
    12781    }
    12882
     
    13387     *
    13488     * @since 1.5.0
     89     * @since 2.5.0 $subject has been unset and is deprecated.
    13590     *
    13691     * @param array  $user_ids Array of user IDs to notify about the update.
    137      * @param string $subject  Email notification subject text.
     92     * @param string $subject  Deprecated in 2.5; now an empty string.
    13893     * @param string $value    Empty string preventing PHP error.
    13994     * @param int    $group_id ID of the group that was updated.
    14095     */
    141     do_action( 'bp_groups_sent_updated_email', $user_ids, $subject, '', $group_id );
     96    do_action( 'bp_groups_sent_updated_email', $user_ids, '', '', $group_id );
    14297}
    14398
     
    151106 * @param int $group_id           ID of the group.
    152107 * @param int $membership_id      ID of the group membership object.
    153  * @return false|null False on failure.
    154108 */
    155109function groups_notification_new_membership_request( $requesting_user_id = 0, $admin_id = 0, $group_id = 0, $membership_id = 0 ) {
     
    168122    // Bail if member opted out of receiving this email.
    169123    if ( 'no' === bp_get_user_meta( $admin_id, 'notification_groups_membership_request', true ) ) {
    170         return false;
    171     }
    172 
    173     // Username of the user requesting a membership: %1$s in mail.
    174     $requesting_user_name = bp_core_get_user_displayname( $requesting_user_id );
    175     $group                = groups_get_group( array( 'group_id' => $group_id ) );
    176 
    177     // Group Administrator user's data.
    178     $ud             = bp_core_get_core_userdata( $admin_id );
    179     $group_requests = bp_get_group_permalink( $group ) . 'admin/membership-requests';
    180 
    181     // Link to the user's profile who's requesting a membership: %3$s in mail.
    182     $profile_link   = bp_core_get_user_domain( $requesting_user_id );
    183 
    184     $settings_slug  = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings';
    185     // Link to the group administrator email settings: %s in "disable notifications" part of the email.
    186     $settings_link  = bp_core_get_user_domain( $admin_id ) . $settings_slug . '/notifications/';
    187 
    188     // Fetch the message, if there's one to fetch.
    189     $membership = new BP_Groups_Member( false, false, $membership_id );
    190 
    191     // Set up and send the message.
    192     $to       = $ud->user_email;
    193     $subject  = bp_get_email_subject( array( 'text' => sprintf( __( 'Membership request for group: %s', 'buddypress' ), $group->name ) ) );
    194 
    195     if ( ! empty( $membership->comments ) ) {
    196         $message = sprintf( __(
    197 '%1$s wants to join the group "%2$s".
    198 
    199 Message from %1$s: "%3$s"
    200 
    201 Because you are the administrator of this group, you must either accept or reject the membership request.
    202 
    203 To view all pending membership requests for this group, please visit:
    204 %4$s
    205 
    206 To view %5$s\'s profile: %6$s
    207 
    208 ---------------------
    209 ', 'buddypress' ), $requesting_user_name, $group->name, esc_html( $membership->comments ), $group_requests, $requesting_user_name, $profile_link );
    210 
    211     } else {
    212 
    213         $message = sprintf( __(
    214 '%1$s wants to join the group "%2$s".
    215 
    216 Because you are the administrator of this group, you must either accept or reject the membership request.
    217 
    218 To view all pending membership requests for this group, please visit:
    219 %3$s
    220 
    221 To view %4$s\'s profile: %5$s
    222 
    223 ---------------------
    224 ', 'buddypress' ), $requesting_user_name, $group->name, $group_requests, $requesting_user_name, $profile_link );
    225     }
    226 
    227     // Only show the disable notifications line if the settings component is enabled.
    228     if ( bp_is_active( 'settings' ) ) {
    229         $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    230     }
    231 
    232     /**
    233      * Filters the user email that the group membership request will be sent to.
    234      *
    235      * @since 1.2.0
    236      *
    237      * @param string $to User email the request is being sent to.
    238      */
    239     $to      = apply_filters( 'groups_notification_new_membership_request_to', $to );
    240 
    241     /**
    242      * Filters the group membership request subject that will be sent to user.
    243      *
    244      * @since 1.2.0
    245      *
    246      * @param string          $subject Membership request email subject text.
    247      * @param BP_Groups_Group $group   Object holding the current group instance. Passed by reference.
    248      */
    249     $subject = apply_filters_ref_array( 'groups_notification_new_membership_request_subject', array( $subject, &$group ) );
    250 
    251     /**
    252      * Filters the group membership request message that will be sent to user.
    253      *
    254      * @since 1.2.0
    255      *
    256      * @param string          $message              Membership request email message text.
    257      * @param BP_Groups_Group $group                Object holding the current group instance. Passed by reference.
    258      * @param string          $requesting_user_name Username of who is requesting membership.
    259      * @param string          $profile_link         URL permalink for the profile for the user requesting membership.
    260      * @param string          $group_requests       URL permalink for the group requests screen for group being requested membership to.
    261      * @param string          $settings_link        URL permalink for the user's notification settings area.
    262      */
    263     $message = apply_filters_ref_array( 'groups_notification_new_membership_request_message', array( $message, &$group, $requesting_user_name, $profile_link, $group_requests, $settings_link ) );
    264 
    265     wp_mail( $to, $subject, $message );
    266 
    267     /**
    268      * Fires after the notification is sent that a member has requested group membership.
    269      *
    270      * @since 1.5.0
    271      *
    272      * @param int    $admin_id           ID of the group administrator.
    273      * @param string $subject            Email notification subject text.
    274      * @param string $message            Email notification message text.
    275      * @param int    $requesting_user_id ID of the user requesting membership.
    276      * @param int    $group_id           ID of the group receiving membership request.
    277      * @param int    $membership_id      ID of the group membership object.
    278      */
    279     do_action( 'bp_groups_sent_membership_request_email', $admin_id, $subject, $message, $requesting_user_id, $group_id, $membership_id );
     124        return;
     125    }
     126
     127    $group = groups_get_group( array( 'group_id' => $group_id ) );
     128    $args  = array(
     129        'tokens' => array(
     130            'admin.id'             => $admin_id,
     131            'group'                => $group,
     132            'group.name'           => $group->name,
     133            'group.id'             => $group_id,
     134            'group-requests.url'   => esc_url( bp_get_group_permalink( $group ) . 'admin/membership-requests' ),
     135            'membership.id'        => $membership_id,
     136            'profile.url'          => esc_url( bp_core_get_user_domain( $requesting_user_id ) ),
     137            'requesting-user.id'   => $requesting_user_id,
     138            'requesting-user.name' => bp_core_get_user_displayname( $requesting_user_id ),
     139        ),
     140    );
     141    bp_send_email( 'groups-membership-request', $admin_id, $args );
    280142}
    281143
     
    289151 * @param bool $accepted           Optional. Whether the membership request was accepted.
    290152 *                                 Default: true.
    291  * @return false|null
    292153 */
    293154function groups_notification_membership_request_completed( $requesting_user_id = 0, $group_id = 0, $accepted = true ) {
     
    297158
    298159        // What type of acknowledgement.
    299         $type = ! empty( $accepted )
    300             ? 'membership_request_accepted'
    301             : 'membership_request_rejected';
     160        $type = ! empty( $accepted ) ? 'membership_request_accepted' : 'membership_request_rejected';
    302161
    303162        bp_notifications_add_notification( array(
     
    305164            'item_id'           => $group_id,
    306165            'component_name'    => buddypress()->groups->id,
    307             'component_action'  => $type
     166            'component_action'  => $type,
    308167        ) );
    309168    }
     
    311170    // Bail if member opted out of receiving this email.
    312171    if ( 'no' === bp_get_user_meta( $requesting_user_id, 'notification_membership_request_completed', true ) ) {
    313         return false;
    314     }
    315 
    316     $group         = groups_get_group( array( 'group_id' => $group_id ) );
    317     $ud            = bp_core_get_core_userdata( $requesting_user_id );
    318     $group_link    = bp_get_group_permalink( $group );
    319     $settings_slug = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings';
    320     $settings_link = bp_core_get_user_domain( $requesting_user_id ) . $settings_slug . '/notifications/';
    321     $to            = $ud->user_email;
    322 
    323     // Set up and send the message.
     172        return;
     173    }
     174
     175    $group = groups_get_group( array( 'group_id' => $group_id ) );
     176    $args  = array(
     177        'tokens' => array(
     178            'group'              => $group,
     179            'group.id'           => $group_id,
     180            'group.name'         => $group->name,
     181            'group.url'          => esc_url( bp_get_group_permalink( $group ) ),
     182            'requesting-user.id' => $requesting_user_id,
     183        ),
     184    );
     185
    324186    if ( ! empty( $accepted ) ) {
    325         $subject = bp_get_email_subject( array( 'text' => sprintf( __( 'Membership request for group "%s" accepted', 'buddypress' ), $group->name ) ) );
    326         $message = sprintf( __(
    327 'Your membership request for the group "%1$s" has been accepted.
    328 
    329 To view the group please login and visit: %2$s
    330 
    331 ---------------------
    332 ', 'buddypress' ), $group->name, $group_link );
    333 
     187        bp_send_email( 'groups-membership-request-accepted', $requesting_user_id, $args );
    334188    } else {
    335         $subject = bp_get_email_subject( array( 'text' => sprintf( __( 'Membership request for group "%s" rejected', 'buddypress' ), $group->name ) ) );
    336         $message = sprintf( __(
    337 'Your membership request for the group "%1$s" has been rejected.
    338 
    339 To submit another request please log in and visit: %2$s
    340 
    341 ---------------------
    342 ', 'buddypress' ), $group->name, $group_link );
    343     }
    344 
    345     // Only show the disable notifications line if the settings component is enabled.
    346     if ( bp_is_active( 'settings' ) ) {
    347         $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    348     }
    349 
    350     /**
    351      * Filters the user email that the group membership request result will be sent to.
    352      *
    353      * @since 1.2.0
    354      *
    355      * @param string $to User email the request result is being sent to.
    356      */
    357     $to      = apply_filters( 'groups_notification_membership_request_completed_to', $to );
    358 
    359     /**
    360      * Filters the group membership request result subject that will be sent to user.
    361      *
    362      * @since 1.2.0
    363      *
    364      * @param string          $subject Membership request result email subject text.
    365      * @param BP_Groups_Group $group   Object holding the current group instance. Passed by reference.
    366      */
    367     $subject = apply_filters_ref_array( 'groups_notification_membership_request_completed_subject', array( $subject, &$group ) );
    368 
    369     /**
    370      * Filters the group membership request result message that will be sent to user.
    371      *
    372      * @since 1.2.0
    373      *
    374      * @param string          $message       Membership request result email message text.
    375      * @param BP_Groups_Group $group         Object holding the current group instance. Passed by reference.
    376      * @param string          $group_link    URL permalink for the group that was requested membership for.
    377      * @param string          $settings_link URL permalink for the user's notification settings area.
    378      */
    379     $message = apply_filters_ref_array( 'groups_notification_membership_request_completed_message', array( $message, &$group, $group_link, $settings_link ) );
    380 
    381     wp_mail( $to, $subject, $message );
    382 
    383     /**
    384      * Fires after the notification is sent that a membership has been approved.
    385      *
    386      * @since 1.5.0
    387      *
    388      * @param int    $requesting_user_id ID of the user whose membership was approved.
    389      * @param string $subject            Email notification subject text.
    390      * @param string $message            Email notification message text.
    391      * @param int    $group_id           ID of the group that was joined.
    392      */
    393     do_action( 'bp_groups_sent_membership_approved_email', $requesting_user_id, $subject, $message, $group_id );
     189        bp_send_email( 'groups-membership-request-rejected', $requesting_user_id, $args );
     190    }
    394191}
    395192add_action( 'groups_membership_accepted', 'groups_notification_membership_request_completed', 10, 3 );
     
    403200 * @param int $user_id  ID of the user.
    404201 * @param int $group_id ID of the group.
    405  * @return false|null False on failure.
    406202 */
    407203function groups_notification_promoted_member( $user_id = 0, $group_id = 0 ) {
     
    422218            'item_id'           => $group_id,
    423219            'component_name'    => buddypress()->groups->id,
    424             'component_action'  => $type
     220            'component_action'  => $type,
    425221        ) );
    426222    }
     
    428224    // Bail if admin opted out of receiving this email.
    429225    if ( 'no' === bp_get_user_meta( $user_id, 'notification_groups_admin_promotion', true ) ) {
    430         return false;
    431     }
    432 
    433     $group         = groups_get_group( array( 'group_id' => $group_id ) );
    434     $ud            = bp_core_get_core_userdata($user_id);
    435     $group_link    = bp_get_group_permalink( $group );
    436     $settings_slug = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings';
    437     $settings_link = bp_core_get_user_domain( $user_id ) . $settings_slug . '/notifications/';
    438 
    439     // Set up and send the message.
    440     $to       = $ud->user_email;
    441     $subject  = bp_get_email_subject( array( 'text' => sprintf( __( 'You have been promoted in the group: "%s"', 'buddypress' ), $group->name ) ) );
    442     $message  = sprintf( __(
    443 'You have been promoted to %1$s for the group: "%2$s".
    444 
    445 To view the group please visit: %3$s
    446 
    447 ---------------------
    448 ', 'buddypress' ), $promoted_to, $group->name, $group_link );
    449 
    450     // Only show the disable notifications line if the settings component is enabled.
    451     if ( bp_is_active( 'settings' ) ) {
    452         $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    453     }
    454 
    455     /**
    456      * Filters the user email that the group promotion notification will be sent to.
    457      *
    458      * @since 1.2.0
    459      *
    460      * @param string $to User email the promotion notification is being sent to.
    461      */
    462     $to      = apply_filters( 'groups_notification_promoted_member_to', $to );
    463 
    464     /**
    465      * Filters the group promotion notification subject that will be sent to user.
    466      *
    467      * @since 1.2.0
    468      *
    469      * @param string          $subject Promotion notification email subject text.
    470      * @param BP_Groups_Group $group   Object holding the current group instance. Passed by reference.
    471      */
    472     $subject = apply_filters_ref_array( 'groups_notification_promoted_member_subject', array( $subject, &$group ) );
    473 
    474     /**
    475      * Filters the group promotion notification message that will be sent to user.
    476      *
    477      * @since 1.2.0
    478      *
    479      * @param string          $message       Promotion notification email message text.
    480      * @param BP_Groups_Group $group         Object holding the current group instance. Passed by reference.
    481      * @param string          $promoted_to   Role that the user was promoted to within the group.
    482      * @param string          $group_link    URL permalink for the group that the promotion was related to.
    483      * @param string          $settings_link URL permalink for the user's notification settings area.
    484      */
    485     $message = apply_filters_ref_array( 'groups_notification_promoted_member_message', array( $message, &$group, $promoted_to, $group_link, $settings_link ) );
    486 
    487     wp_mail( $to, $subject, $message );
    488 
    489     /**
    490      * Fires after the notification is sent that a member has been promoted.
    491      *
    492      * @since 1.5.0
    493      *
    494      * @param int    $user_id  ID of the user who was promoted.
    495      * @param string $subject  Email notification subject text.
    496      * @param string $message  Email notification message text.
    497      * @param int    $group_id ID of the group that the user is a member of.
    498      */
    499     do_action( 'bp_groups_sent_promoted_email', $user_id, $subject, $message, $group_id );
     226        return;
     227    }
     228
     229    $group = groups_get_group( array( 'group_id' => $group_id ) );
     230    $args  = array(
     231        'tokens' => array(
     232            'group'       => $group,
     233            'group.id'    => $group_id,
     234            'group.url'   => esc_url( bp_get_group_permalink( $group ) ),
     235            'group.name'  => $group->name,
     236            'promoted_to' => $promoted_to,
     237            'user.id'     => $user_id,
     238        ),
     239    );
     240    bp_send_email( 'groups-member-promoted', $user_id, $args );
    500241}
    501242add_action( 'groups_promoted_member', 'groups_notification_promoted_member', 10, 2 );
     
    509250 * @param BP_Groups_Member $member          Member object.
    510251 * @param int              $inviter_user_id ID of the user who sent the invite.
    511  * @return null|false False on failure.
    512252 */
    513253function groups_notification_group_invites( &$group, &$member, $inviter_user_id ) {
     
    519259
    520260    // @todo $inviter_ud may be used for caching, test without it
    521     $inviter_ud   = bp_core_get_core_userdata( $inviter_user_id );
    522     $inviter_name = bp_core_get_userlink( $inviter_user_id, true, false, true );
    523     $inviter_link = bp_core_get_user_domain( $inviter_user_id );
    524     $group_link   = bp_get_group_permalink( $group );
    525 
    526     // Setup the ID for the invited user.
     261    $inviter_ud      = bp_core_get_core_userdata( $inviter_user_id );
    527262    $invited_user_id = $member->user_id;
    528263
     
    533268            'item_id'          => $group->id,
    534269            'component_name'   => buddypress()->groups->id,
    535             'component_action' => 'group_invite'
     270            'component_action' => 'group_invite',
    536271        ) );
    537272    }
     
    539274    // Bail if member opted out of receiving this email.
    540275    if ( 'no' === bp_get_user_meta( $invited_user_id, 'notification_groups_invite', true ) ) {
    541         return false;
    542     }
    543 
    544     $invited_ud    = bp_core_get_core_userdata( $invited_user_id );
    545     $settings_slug = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings';
    546     $settings_link = bp_core_get_user_domain( $invited_user_id ) . $settings_slug . '/notifications/';
    547     $invited_link  = bp_core_get_user_domain( $invited_user_id );
    548     $invites_link  = trailingslashit( $invited_link . bp_get_groups_slug() . '/invites' );
    549 
    550     // Set up and send the message.
    551     $to       = $invited_ud->user_email;
    552     $subject  = bp_get_email_subject( array( 'text' => sprintf( __( 'You have an invitation to the group: "%s"', 'buddypress' ), $group->name ) ) );
    553     $message  = sprintf( __(
    554 'One of your friends %1$s has invited you to the group: "%2$s".
    555 
    556 To view your group invites visit: %3$s
    557 
    558 To view the group visit: %4$s
    559 
    560 To view %5$s\'s profile visit: %6$s
    561 
    562 ---------------------
    563 ', 'buddypress' ), $inviter_name, $group->name, $invites_link, $group_link, $inviter_name, $inviter_link );
    564 
    565     // Only show the disable notifications line if the settings component is enabled.
    566     if ( bp_is_active( 'settings' ) ) {
    567         $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    568     }
    569 
    570     /**
    571      * Filters the user email that the group invite notification will be sent to.
    572      *
    573      * @since 1.2.0
    574      *
    575      * @param string $to User email the invite notification is being sent to.
    576      */
    577     $to      = apply_filters( 'groups_notification_group_invites_to', $to );
    578 
    579     /**
    580      * Filters the group invite notification subject that will be sent to user.
    581      *
    582      * @since 1.2.0
    583      *
    584      * @param string          $subject Invite notification email subject text.
    585      * @param BP_Groups_Group $group   Object holding the current group instance. Passed by reference.
    586      */
    587     $subject = apply_filters_ref_array( 'groups_notification_group_invites_subject', array( $subject, &$group ) );
    588 
    589     /**
    590      * Filters the group invite notification message that will be sent to user.
    591      *
    592      * @since 1.2.0
    593      *
    594      * @param string          $message       Invite notification email message text.
    595      * @param BP_Groups_Group $group         Object holding the current group instance. Passed by reference.
    596      * @param string          $inviter_name  Username for the person doing the inviting.
    597      * @param string          $inviter_link  Profile link for the person doing the inviting.
    598      * @param string          $invites_link  URL permalink for the invited user's invite management screen.
    599      * @param string          $group_link    URL permalink for the group that the invite was related to.
    600      * @param string          $settings_link URL permalink for the user's notification settings area.
    601      */
    602     $message = apply_filters_ref_array( 'groups_notification_group_invites_message', array( $message, &$group, $inviter_name, $inviter_link, $invites_link, $group_link, $settings_link ) );
    603 
    604     wp_mail( $to, $subject, $message );
    605 
    606     /**
    607      * Fires after the notification is sent that a member has been invited to a group.
    608      *
    609      * @since 1.5.0
    610      *
    611      * @param int             $invited_user_id  ID of the user who was invited.
    612      * @param string          $subject          Email notification subject text.
    613      * @param string          $message          Email notification message text.
    614      * @param BP_Groups_Group $group            Group object.
    615      */
    616     do_action( 'bp_groups_sent_invited_email', $invited_user_id, $subject, $message, $group );
     276        return;
     277    }
     278
     279    $invited_link = bp_core_get_user_domain( $invited_user_id ) . bp_get_groups_slug();
     280    $args         = array(
     281        'tokens' => array(
     282            'group'                => $group,
     283            'group.url'            => bp_get_group_permalink( $group ),
     284            'group.name'           => $group->name,
     285            'inviter-profile.id'   => $invited_user_id,
     286            'inviter-profile.name' => bp_core_get_userlink( $inviter_user_id, true, false, true ),
     287            'inviter-profile.url'  => bp_core_get_user_domain( $inviter_user_id ),
     288            'invites.url'          => esc_url( $invited_link . '/invites/' ),
     289        ),
     290    );
     291    bp_send_email( 'groups-invitation', $invited_user_id, $args );
    617292}
    618293
Note: See TracChangeset for help on using the changeset viewer.