Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/31/2015 05:37:08 AM (10 years ago)
Author:
johnjamesjacoby
Message:

Groups: Updates to delete_invite() method:

  • Add brackets around if condition
  • Break query apart into separate lines for better readability
  • Add inviter_id != 0 condition to query (note that this means not using $wpdb->delete())

Fixes a regression (from r9810) causing group membership invitations to be irreversible if the form was not submitted first.

Fixes #6462. Props dcavins, imath.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-groups/classes/class-bp-groups-member.php

    r9819 r9901  
    722722     * Delete an invitation, by specifying user ID and group ID.
    723723     *
    724      * @param int $user_id ID of the user.
    725      * @param int $group_id ID of the group.
     724     * @global WPDB $wpdb
     725     *
     726     * @param  int $user_id  ID of the user.
     727     * @param  int $group_id ID of the group.
    726728     * @return int Number of records deleted.
    727729     */
     
    729731        global $wpdb;
    730732
    731         if ( empty( $user_id ) )
    732             return false;
    733 
    734         $bp = buddypress();
    735 
    736         return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_confirmed = 0 AND inviter_id != 0 AND invite_sent = 1", $user_id, $group_id ) );
     733        if ( empty( $user_id ) ) {
     734            return false;
     735        }
     736
     737        $table_name = buddypress()->groups->table_name_members;
     738
     739        $sql = "DELETE FROM {$table_name}
     740                WHERE user_id = %d
     741                    AND group_id = %d
     742                    AND is_confirmed = 0
     743                    AND inviter_id != 0";
     744
     745        $prepared = $wpdb->prepare( $sql, $user_id, $group_id );
     746
     747        return $wpdb->query( $prepared );
    737748    }
    738749
Note: See TracChangeset for help on using the changeset viewer.