Skip to:
Content

BuddyPress.org

Changeset 13172


Ignore:
Timestamp:
12/10/2021 04:15:30 PM (22 months ago)
Author:
dcavins
Message:

Membership Requests: Invitation interaction

If a user makes a registration request and is also
an invitee to the site, immediately approve the request.

See #8582.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/classes/class-bp-invitation-manager.php

    r13108 r13172  
    228228     *     @type int    $secondary_item_id secondary ID associated with the
    229229     *                  invitation and class.
    230      *     @type string $type @TODO. < missing description.
     230     *     @type string $type    Type of record this is: 'invite' or 'request'.
    231231     *     @type string $content Extra information provided by the requester
    232232     *                  or inviter.
  • trunk/src/bp-members/bp-members-invitations.php

    r13125 r13172  
    184184}
    185185add_action( 'bp_optout_after_save', 'bp_members_invitations_delete_optedout_invites' );
     186
     187/**
     188 * If a user submits a site membership request, but there's a
     189 * sent invitation to her, bypass the manual approval of the request.
     190 *
     191 * @since 10.0.0
     192 *
     193 * @param bool  $send    Whether or not this membership request should be approved
     194 *                       immediately and the activation email sent.
     195 *                       Default is `false` meaning that the request should be
     196 *                       manually approved by a site admin.
     197 * @param array $details The details of the request.
     198 */
     199function bp_members_invitations_maybe_bypass_request_approval( $send, $details ) {
     200    if ( ! bp_get_members_invitations_allowed() ) {
     201        return $send;
     202    }
     203
     204    // We'll need the prospective user's email address.
     205    if ( empty( $details['user_email'] ) ) {
     206        return $send;
     207    }
     208
     209    $invites = bp_members_invitations_get_invites(
     210        array(
     211            'invitee_email' => $details['user_email'],
     212            'invite_sent'   => 'sent'
     213        )
     214    );
     215
     216    // If pending invitations exist, send the verification mail.
     217    if ( $invites ) {
     218        $send = true;
     219    }
     220
     221    return $send;
     222}
     223add_filter( 'bp_members_membership_requests_bypass_manual_approval', 'bp_members_invitations_maybe_bypass_request_approval', 10, 2 );
     224add_filter( 'bp_members_membership_requests_bypass_manual_approval_multisite', 'bp_members_invitations_maybe_bypass_request_approval', 10, 2 );
Note: See TracChangeset for help on using the changeset viewer.