Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/13/2008 11:20:15 PM (18 years ago)
Author:
apeatling
Message:

Added ability for group admins to:

  • Promote users to moderators
  • Demote users to regular group members
  • Ban and kick users from a group
File:
1 edited

Legend:

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

    r515 r540  
    175175}
    176176
     177function groups_notification_promoted_member( $user_id, $group_id ) {
     178        global $bp, $current_user;
     179
     180        if ( groups_is_user_admin( $user_id, $group_id ) ) {
     181                $promoted_to = 'admin';
     182                $type = 'member_promoted_to_admin';
     183        } else {
     184                $promoted_to = 'mod';
     185                $type = 'member_promoted_to_mod';
     186        }
     187       
     188        // Post a screen notification first.
     189        bp_core_add_notification( $group_id, $user_id, 'groups', $type );
     190
     191        if ( get_usermeta( $user_id, 'notification_group_promotion' ) == 'no' )
     192                return false;
     193
     194        $group = new BP_Groups_Group( $group_id, false, false );
     195        $ud = get_userdata($user_id);
     196
     197        $group_link = bp_group_permalink( $group, false );
     198        $settings_link = site_url() . '/' . MEMBERS_SLUG . '/' . $ud->user_login . '/settings/notifications';
     199
     200        // Set up and send the message
     201        $to = $ud->user_email;
     202
     203        $subject = sprintf( __( 'You have been promoted in the group: "%s"', 'buddypress' ), stripslashes($group->name) );
     204
     205                $message = sprintf( __(
     206'You have been promoted to % for the group: "%s".
     207
     208To view the group please visit: %s
     209
     210---------------------
     211', 'buddypress' ), stripslashes($group->name), $group_link );
     212
     213        $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
     214
     215        // Send it
     216        wp_mail( $to, $subject, $message );
     217}
     218add_action( 'bp_groups_promoted_member', 'groups_notification_promoted_member', 10, 2 );
     219
    177220?>
Note: See TracChangeset for help on using the changeset viewer.