diff --git src/bp-groups/actions/join.php src/bp-groups/actions/join.php
index 812d6e33b..d71b62d5a 100644
|
|
|
function groups_action_join_group() { |
| 18 | 18 | return; |
| 19 | 19 | } |
| 20 | 20 | |
| | 21 | /* |
| | 22 | * Ensure that the invite_status key exists, to avoid a group being joinable when its |
| | 23 | * creation process was interrupted. |
| | 24 | */ |
| | 25 | if ( ! groups_get_groupmeta( bp_get_current_group_id(), 'invite_status' ) ) { |
| | 26 | return; |
| | 27 | } |
| | 28 | |
| 21 | 29 | // Nonce check. |
| 22 | 30 | if ( ! check_admin_referer( 'groups_join_group' ) ) { |
| 23 | 31 | return; |
diff --git src/bp-groups/bp-groups-functions.php src/bp-groups/bp-groups-functions.php
index 755293356..7c73b2fd9 100644
|
|
|
function groups_join_group( $group, $user_id = 0 ) { |
| 664 | 664 | |
| 665 | 665 | $group = bp_get_group( $group ); |
| 666 | 666 | |
| 667 | | /* |
| 668 | | * When the group create first step is completed, the group's status has not been defined by the |
| 669 | | * group creator yet and defaults to public. As the group status & the invite status are set once |
| 670 | | * the group create second step is completed, we need to wait for this step to be achieved to let |
| 671 | | * users join the group being created otherwise it would be possible for a user to "pre-join" a |
| 672 | | * private/hidden group. Checking if the invite status is set is the only way to make sure this |
| 673 | | * second step has been completed. If it's not the case, no need to go further. |
| 674 | | */ |
| 675 | | if ( empty( $group->id ) || ! groups_get_groupmeta( $group->id, 'invite_status' ) ) { |
| | 667 | if ( empty( $group->id ) ) { |
| 676 | 668 | return false; |
| 677 | 669 | } |
| 678 | 670 | |
diff --git src/bp-templates/bp-legacy/buddypress-functions.php src/bp-templates/bp-legacy/buddypress-functions.php
index 809dc0ac7..8d5927298 100644
|
|
|
function bp_legacy_theme_ajax_joinleave_group() { |
| 1616 | 1616 | esc_html_e( 'Error joining group', 'buddypress' ); |
| 1617 | 1617 | } |
| 1618 | 1618 | |
| | 1619 | /* |
| | 1620 | * Ensure that the invite_status key exists, to avoid a group |
| | 1621 | * being joinable when its creation process was interrupted. |
| | 1622 | */ |
| | 1623 | if ( ! groups_get_groupmeta( $group->id, 'invite_status' ) ) { |
| | 1624 | esc_html_e( 'Error joining group', 'buddypress' ); |
| | 1625 | break; |
| | 1626 | } |
| | 1627 | |
| 1619 | 1628 | check_ajax_referer( 'groups_join_group' ); |
| 1620 | 1629 | |
| 1621 | 1630 | if ( ! groups_join_group( $group->id ) ) { |
diff --git src/bp-templates/bp-nouveau/includes/groups/ajax.php src/bp-templates/bp-nouveau/includes/groups/ajax.php
index 7e9f5b490..ce5c3aa16 100644
|
|
|
function bp_nouveau_ajax_joinleave_group() { |
| 173 | 173 | 'feedback' => $errors['cannot'], |
| 174 | 174 | 'type' => 'error', |
| 175 | 175 | ); |
| 176 | | } elseif ( ! groups_join_group( $group->id ) ) { |
| 177 | | $response = array( |
| 178 | | 'feedback' => sprintf( |
| 179 | | '<div class="bp-feedback error"><span class="bp-icon" aria-hidden="true"></span><p>%s</p></div>', |
| 180 | | esc_html__( 'Error joining this group.', 'buddypress' ) |
| 181 | | ), |
| 182 | | 'type' => 'error', |
| 183 | | ); |
| 184 | | } else { |
| 185 | | // User is now a member of the group |
| 186 | | $group->is_member = '1'; |
| | 176 | } elseif ( groups_get_groupmeta( $group->id, 'invite_status' ) && ! groups_join_group( $group->id ) ) { |
| | 177 | $response = array( |
| | 178 | 'feedback' => sprintf( |
| | 179 | '<div class="bp-feedback error"><span class="bp-icon" aria-hidden="true"></span><p>%s</p></div>', |
| | 180 | esc_html__( 'Error joining this group.', 'buddypress' ) |
| | 181 | ), |
| | 182 | 'type' => 'error', |
| | 183 | ); |
| | 184 | } else { |
| | 185 | // User is now a member of the group |
| | 186 | $group->is_member = '1'; |
| 187 | 187 | |
| 188 | | $response = array( |
| 189 | | 'contents' => bp_get_group_join_button( $group ), |
| 190 | | 'is_group' => bp_is_group(), |
| 191 | | 'type' => 'success', |
| 192 | | ); |
| 193 | | } |
| | 188 | $response = array( |
| | 189 | 'contents' => bp_get_group_join_button( $group ), |
| | 190 | 'is_group' => bp_is_group(), |
| | 191 | 'type' => 'success', |
| | 192 | ); |
| | 193 | } |
| 194 | 194 | break; |
| 195 | 195 | |
| 196 | 196 | case 'groups_request_membership' : |