Skip to:
Content

BuddyPress.org

Changeset 13346


Ignore:
Timestamp:
10/26/2022 09:06:02 PM (4 years ago)
Author:
dcavins
Message:

Site invitations: Do not assume that a user exists.

In some BuddyPress setups, a user is not created
until the signup has been activated. This is the case
when BP_SIGNUPS_SKIP_USER_CREATION is set
to true or when BP is installed on a WodPress network.
So we rely on the BP_Signup instead of the dodgy
user_id in bp_members_invitations_complete_signup().

Fixes #8693.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-members/bp-members-invitations.php

    r13172 r13346  
    106106        $bp = buddypress();
    107107
    108         if ( ! $user_id ) {
    109                 return;
    110         }
    111 
    112108        // Check to see if this signup is the result of a valid invitation.
    113109        $invite = bp_get_members_invitation_from_request();
     
    116112        }
    117113
    118         // Accept the invitation.
    119         $invites_class = new BP_Members_Invitation_Manager();
    120         $args          = array(
    121                 'id' => $invite->id,
    122         );
    123         $invites_class->accept_invitation( $args );
    124 
    125114        // User has already verified their email by responding to the invitation, so we can activate.
    126         $key = bp_get_user_meta( $user_id, 'activation_key', true );
     115        $signup = bp_members_get_signup_by( 'user_email', $invite->invitee_email );
     116        $key = false;
     117        if ( ! empty( $signup->activation_key ) ) {
     118                $key = $signup->activation_key;
     119        }
     120
    127121        if ( $key ) {
    128122                $redirect = bp_get_activation_page();
     
    137131                 */
    138132                $user = apply_filters( 'bp_core_activate_account', bp_core_activate_signup( $key ) );
     133
     134                // Accept the invitation now that the user has been created.
     135                $invites_class = new BP_Members_Invitation_Manager();
     136                $args          = array(
     137                        'id' => $invite->id,
     138                );
     139                $invites_class->accept_invitation( $args );
    139140
    140141                // If there were errors, add a message and redirect.
Note: See TracChangeset for help on using the changeset viewer.