Skip to:
Content

BuddyPress.org

Changeset 2955


Ignore:
Timestamp:
04/26/2010 11:57:07 PM (15 years ago)
Author:
johnjamesjacoby
Message:

Fixes #2336 props boonebgorges (turkey!)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.2/bp-groups.php

    r2954 r2955  
    11851185        return false;
    11861186
     1187    // Nonce check
     1188    if ( !check_admin_referer( 'groups_join_group' ) )
     1189        return false;
     1190
    11871191    // Skip if banned or already a member
    11881192    if ( !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) && !groups_is_user_banned( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) {
     
    12081212}
    12091213add_action( 'wp', 'groups_action_join_group', 3 );
     1214
     1215
     1216function groups_action_leave_group() {
     1217    global $bp;
     1218
     1219    if ( !$bp->is_single_item || $bp->current_component != $bp->groups->slug || $bp->current_action != 'leave-group' )
     1220        return false;
     1221
     1222    // Nonce check
     1223    if ( !check_admin_referer( 'groups_leave_group' ) )
     1224        return false;
     1225
     1226    // User wants to leave any group
     1227    if ( groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) {
     1228        if ( !groups_leave_group( $bp->groups->current_group->id ) ) {
     1229            bp_core_add_message( __( 'There was an error leaving the group.', 'buddypress' ), 'error' );
     1230        } else {
     1231            bp_core_add_message( __( 'You successfully left the group.', 'buddypress' ) );
     1232        }
     1233        bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
     1234    }
     1235
     1236    bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) );
     1237}
     1238add_action( 'wp', 'groups_action_leave_group', 3 );
     1239
    12101240
    12111241function groups_action_sort_creation_steps() {
Note: See TracChangeset for help on using the changeset viewer.