Skip to:
Content

BuddyPress.org

Ticket #7875: 7875.patch

File 7875.patch, 2.7 KB (added by imath, 3 years ago)
  • src/bp-templates/bp-nouveau/includes/groups/ajax.php

    diff --git src/bp-templates/bp-nouveau/includes/groups/ajax.php src/bp-templates/bp-nouveau/includes/groups/ajax.php
    index c11df9d2e..9714f81a8 100644
    function bp_nouveau_ajax_send_group_invites() { 
    394394        if ( ! empty( $_POST['message'] ) ) {
    395395                $bp->groups->invites_message = wp_kses( wp_unslash( $_POST['message'] ), array() );
    396396
    397                 add_filter( 'groups_notification_group_invites_message', 'bp_nouveau_groups_invites_custom_message', 10, 1 );
     397                add_filter( 'bp_email_set_post_object', 'bp_nouveau_groups_invites_custom_message', 10, 2 );
    398398        }
    399399
    400400        // Send the invites.
    function bp_nouveau_ajax_send_group_invites() { 
    403403        if ( ! empty( $_POST['message'] ) ) {
    404404                unset( $bp->groups->invites_message );
    405405
    406                 remove_filter( 'groups_notification_group_invites_message', 'bp_nouveau_groups_invites_custom_message', 10, 1 );
     406                remove_filter( 'bp_email_set_post_object', 'bp_nouveau_groups_invites_custom_message', 10, 2 );
    407407        }
    408408
    409409        if ( array_search( false, $invited ) ) {
  • src/bp-templates/bp-nouveau/includes/groups/functions.php

    diff --git src/bp-templates/bp-nouveau/includes/groups/functions.php src/bp-templates/bp-nouveau/includes/groups/functions.php
    index cf85567dc..bf59fd239 100644
    function bp_nouveau_group_setup_nav() { 
    349349}
    350350
    351351/**
    352  * @since 3.0.0
     352 * Append the Group Invites message to the email sent.
     353 *
     354 * @since 3.0.0 Filters 'groups_notification_group_invites_message'
     355 * @since 3.0.1 Filters 'bp_email_set_post_object' instead of the deprecated
     356 *                      'groups_notification_group_invites_message' filter.
     357 *
     358 * @param  WP_Post  $post  The post object containing html & plain email text.
     359 * @param  BP_Email $email The email (object) about to be sent.
     360 * @return WP_Post         The post object containing html & plain email text.
    353361 */
    354 function bp_nouveau_groups_invites_custom_message( $message = '' ) {
    355         if ( empty( $message ) ) {
    356                 return $message;
    357         }
    358 
     362function bp_nouveau_groups_invites_custom_message( WP_Post $post, BP_Email $email ) {
    359363        $bp = buddypress();
    360364
    361         if ( empty( $bp->groups->invites_message ) ) {
    362                 return $message;
     365        if ( empty( $bp->groups->invites_message ) || ! $post->ID ) {
     366                return $post;
    363367        }
    364368
    365         $message = str_replace( '---------------------', "
    366 ---------------------\n
    367 " . $bp->groups->invites_message . "\n
    368 ---------------------
    369         ", $message );
     369        $message = wp_strip_all_tags( $bp->groups->invites_message );
    370370
    371         return $message;
     371        // Edit the rich and plain text email contents.
     372        $post->post_content .= "\n" . $message;
     373        $post->post_excerpt .= "\n\n" . $message;
     374
     375        return $post;
    372376}
    373377
    374378/**