Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/09/2014 07:18:31 PM (11 years ago)
Author:
boonebgorges
Message:

Remove Invite noscript support for group invitations screens

Fixes #5281

Props imath

File:
1 edited

Legend:

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

    r8090 r8093  
    447447    }
    448448}
     449
     450/**
     451 * Process group invitation removal requests.
     452 *
     453 * Note that this function is only used when JS is disabled. Normally, clicking
     454 * Remove Invite removes the invitation via AJAX.
     455 *
     456 * @since BuddyPress (2.0.0)
     457 */
     458function groups_remove_group_invite() {
     459    if ( ! bp_is_group_invites() ) {
     460        return;
     461    }
     462
     463    if ( ! bp_is_action_variable( 'remove', 0 ) || ! is_numeric( bp_action_variable( 1 ) ) ) {
     464        return;
     465    }
     466
     467    if ( ! check_admin_referer( 'groups_invite_uninvite_user' ) ) {
     468        return false;
     469    }
     470
     471    $friend_id = intval( bp_action_variable( 1 ) );
     472    $group_id  = bp_get_current_group_id();
     473    $message   = __( 'Invite successfully removed', 'buddypress' );
     474    $redirect  = wp_get_referer();
     475    $error     = false;
     476
     477    if ( ! bp_groups_user_can_send_invites( $group_id ) ) {
     478        $message = __( 'You are not allowed to send or remove invites', 'buddypress' );
     479        $error = 'error';
     480    } else if ( BP_Groups_Member::check_for_membership_request( $friend_id, $group_id ) ) {
     481        $message = __( 'The member requested to join the group', 'buddypress' );
     482        $error = 'error';
     483    } else if ( ! groups_uninvite_user( $friend_id, $group_id ) ) {
     484        $message = __( 'There was an error removing the invite', 'buddypress' );
     485        $error = 'error';
     486    }
     487
     488    bp_core_add_message( $message, $error );
     489    bp_core_redirect( $redirect );
     490}
     491add_action( 'bp_screens', 'groups_remove_group_invite' );
    449492
    450493function groups_screen_group_request_membership() {
Note: See TracChangeset for help on using the changeset viewer.