groups_notification_promoted_member( int $user_id, int $group_id )

Notify group member they have been promoted.

Description

Parameters

$user_id

(Required) ID of the user.

$group_id

(Required) ID of the group.

Source

File: bp-groups/bp-groups-notifications.php

253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
function groups_notification_promoted_member( $user_id = 0, $group_id = 0 ) {
 
    // What type of promotion is this?
    if ( groups_is_user_admin( $user_id, $group_id ) ) {
        $promoted_to = __( 'organizer', 'buddyboss' );
        $type        = 'member_promoted_to_admin';
    } else {
        $promoted_to = __( 'moderator', 'buddyboss' );
        $type        = 'member_promoted_to_mod';
    }
 
    // Trigger a BuddyPress Notification.
    if ( bp_is_active( 'notifications' ) ) {
        bp_notifications_add_notification( array(
            'user_id'           => $user_id,
            'item_id'           => $group_id,
            'component_name'    => buddypress()->groups->id,
            'component_action'  => $type,
        ) );
    }
 
    // Bail if admin opted out of receiving this email.
    if ( 'no' === bp_get_user_meta( $user_id, 'notification_groups_admin_promotion', true ) ) {
        return;
    }
 
    $unsubscribe_args = array(
        'user_id'           => $user_id,
        'notification_type' => 'groups-member-promoted',
    );
 
    $group = groups_get_group( $group_id );
    $args  = array(
        'tokens' => array(
            'group'       => $group,
            'group.id'    => $group_id,
            'group.url'   => esc_url( bp_get_group_permalink( $group ) ),
            'group.name'  => $group->name,
            'promoted_to' => $promoted_to,
            'user.id'     => $user_id,
            'unsubscribe' => esc_url( bp_email_get_unsubscribe_link( $unsubscribe_args ) ),
        ),
    );
    bp_send_email( 'groups-member-promoted', (int) $user_id, $args );
}

Changelog

Changelog
Version Description
BuddyPress 1.0.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.