Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/22/2022 05:42:45 AM (3 years ago)
Author:
imath
Message:

List the displayed user groups invites in member's front-end screen

As a site admin can view the displayed user groups invites, listed invites have to be the one of this user and not the ones of the site admin.

Adapt the Group Invites feature so that site admins can accept or reject on behalf of the displayed user the listed invites. These two actions made by an admin will generate a specific BP Email informing the user of it.

Props oztaser, dcavins, espellcaste

Closes https://github.com/buddypress/buddypress/pull/15
Fixes #8675

File:
1 edited

Legend:

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

    r13034 r13273  
    12231223}
    12241224add_action( 'bp_notification_settings', 'groups_screen_notification_settings' );
     1225
     1226/**
     1227 * Notify member about their group membership request accepted/rejected by admin.
     1228 *
     1229 * @since 11.0.0
     1230 *
     1231 * @param int $user_id  ID of the user requesting group membership.
     1232 * @param int $group_id ID of the group.
     1233 */
     1234function groups_email_notification_membership_request_completed_by_admin( $user_id, $group_id ) {
     1235    if ( (int) $user_id === bp_loggedin_user_id() ) {
     1236        return;
     1237    }
     1238
     1239    if ( false === bp_current_user_can( 'bp_moderate' ) ) {
     1240        return;
     1241    }
     1242
     1243    $group = groups_get_group( $group_id );
     1244    if ( true === empty( $group->id ) ) {
     1245        return;
     1246    }
     1247
     1248    $args = array(
     1249        'tokens' => array(
     1250            'group'           => $group,
     1251            'group.id'        => $group_id,
     1252            'group.name'      => $group->name,
     1253            'group.url'       => esc_url( bp_get_group_permalink( $group ) ),
     1254            'leave-group.url' => esc_url( bp_core_get_user_domain( $user_id ) . bp_get_groups_slug() ),
     1255        ),
     1256    );
     1257
     1258    $email_type = 'groups-membership-request-accepted-by-admin';
     1259    if ( true === doing_action( 'groups_reject_invite' ) ) {
     1260        unset( $args['tokens']['leave-group.url'] );
     1261        $email_type = 'groups-membership-request-rejected-by-admin';
     1262    }
     1263
     1264    bp_send_email( $email_type, (int) $user_id, $args );
     1265}
     1266add_action( 'groups_accept_invite', 'groups_email_notification_membership_request_completed_by_admin', 10, 2 );
     1267add_action( 'groups_reject_invite', 'groups_email_notification_membership_request_completed_by_admin', 10, 2 );
Note: See TracChangeset for help on using the changeset viewer.