Skip to:
Content

BuddyPress.org

Ticket #9241: 9241.diff

File 9241.diff, 4.0 KB (added by boonebgorges, 9 months ago)
  • src/bp-groups/actions/join.php

    diff --git src/bp-groups/actions/join.php src/bp-groups/actions/join.php
    index 812d6e33b..d71b62d5a 100644
    function groups_action_join_group() { 
    1818                return;
    1919        }
    2020
     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
    2129        // Nonce check.
    2230        if ( ! check_admin_referer( 'groups_join_group' ) ) {
    2331                return;
  • src/bp-groups/bp-groups-functions.php

    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 ) { 
    664664
    665665        $group = bp_get_group( $group );
    666666
    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 ) ) {
    676668                return false;
    677669        }
    678670
  • src/bp-templates/bp-legacy/buddypress-functions.php

    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() { 
    16161616                                esc_html_e( 'Error joining group', 'buddypress' );
    16171617                        }
    16181618
     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
    16191628                        check_ajax_referer( 'groups_join_group' );
    16201629
    16211630                        if ( ! groups_join_group( $group->id ) ) {
  • src/bp-templates/bp-nouveau/includes/groups/ajax.php

    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() { 
    173173                                        'feedback' => $errors['cannot'],
    174174                                        'type'     => 'error',
    175175                                );
    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';
    187187
    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                                }
    194194                        break;
    195195
    196196                        case 'groups_request_membership' :