Skip to:
Content

BuddyPress.org

Changeset 9226


Ignore:
Timestamp:
12/10/2014 03:50:08 PM (9 years ago)
Author:
boonebgorges
Message:

Include updated name/description in email notification after a group is updated.

When updating a group's details, there's a checkbox that asks "Notify group
members?". But the notification that goes out does not currently contain any
information about what was changed. The current changeset adds this information
to the email text.

Fixes #5879.

Location:
trunk/src/bp-groups
Files:
2 edited

Legend:

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

    r9204 r9226  
    201201
    202202    if ( $notify_members ) {
    203         groups_notification_group_updated( $group->id );
     203        groups_notification_group_updated( $group->id, $old_group );
    204204    }
    205205
  • trunk/src/bp-groups/bp-groups-notifications.php

    r9170 r9226  
    2222 *
    2323 * @param int $group_id ID of the group.
    24  */
    25 function groups_notification_group_updated( $group_id = 0 ) {
    26 
    27     $group    = groups_get_group( array( 'group_id' => $group_id ) );
     24 * @param BP_Groups_Group $old_group Group before new details were saved.
     25 */
     26function groups_notification_group_updated( $group_id = 0, $old_group = null ) {
     27
     28    $group = groups_get_group( array( 'group_id' => $group_id ) );
     29
     30    if ( $old_group instanceof BP_Groups_Group ) {
     31        $changed = array();
     32
     33        if ( $group->name !== $old_group->name ) {
     34            $changed[] = sprintf(
     35                _x( '* Name changed from "%s" to "%s"', 'Group update email text', 'buddypress' ),
     36                esc_html( $old_group->name ),
     37                esc_html( $group->name )
     38            );
     39        }
     40
     41        if ( $group->description !== $old_group->description ) {
     42            $changed[] = sprintf(
     43                __( '* Description changed from "%s" to "%s"', 'Group update email text', 'buddypress' ),
     44                esc_html( $old_group->description ),
     45                esc_html( $group->description )
     46            );
     47        }
     48    }
     49
     50    /**
     51     * Filters the bullet points listing updated items in the email notification after a group is updated.
     52     *
     53     * @since BuddyPress (2.2.0)
     54     *
     55     * @param array $changed Array of bullet points.
     56     */
     57    $changed = apply_filters( 'groups_notification_group_update_updated_items', $changed );
     58
     59    $changed_text = '';
     60    if ( ! empty( $changed ) ) {
     61        $changed_text = "\n\n" . implode( "\n", $changed );
     62    }
     63
    2864    $subject  = bp_get_email_subject( array( 'text' => __( 'Group Details Updated', 'buddypress' ) ) );
    2965    $user_ids = BP_Groups_Member::get_group_member_ids( $group->id );
     
    4682
    4783        $message = sprintf( __(
    48 'Group details for the group "%1$s" were updated:
    49 
    50 To view the group: %2$s
     84'Group details for the group "%1$s" were updated: %2$s
     85
     86To view the group: %3$s
    5187
    5288---------------------
    53 ', 'buddypress' ), $group->name, $group_link );
     89', 'buddypress' ), $group->name, $changed_text, $group_link );
    5490
    5591        $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
Note: See TracChangeset for help on using the changeset viewer.