Skip to:
Content

BuddyPress.org

Changeset 14043


Ignore:
Timestamp:
10/10/2024 07:55:18 PM (4 weeks ago)
Author:
imath
Message:

Move the invite_status group meta check out of groups_join_group()

[13874] introduced a regression where groups whose creation process is abandoned become unjoinable & or when using the WP BuddyPress CLI to create groups.

To avoid this, we now perform the check higher up the chain, namely in the places in BuddyPress where groups_join_group() is called.

Props boonebgorges, vapvarun.

See #9241 (trunk)
Fixes #9238
Closes https://github.com/buddypress/buddypress/pull/381

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-groups/actions/join.php

    r13882 r14043  
    1616
    1717    if ( ! bp_is_single_item() || ! bp_is_groups_component() || ! bp_is_current_action( 'join' ) ) {
     18        return;
     19    }
     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' ) ) {
    1826        return;
    1927    }
  • trunk/src/bp-groups/bp-groups-functions.php

    r14024 r14043  
    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    }
  • trunk/src/bp-templates/bp-legacy/buddypress-functions.php

    r14013 r14043  
    16151615            if ( ! bp_current_user_can( 'groups_join_group', array( 'group_id' => $group->id ) ) ) {
    16161616                esc_html_e( 'Error joining group', 'buddypress' );
     1617            }
     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;
    16171626            }
    16181627
  • trunk/src/bp-templates/bp-nouveau/includes/groups/ajax.php

    r13878 r14043  
    169169                    'type'     => 'error',
    170170                );
    171             } elseif ( 'public' !== $group->status ) {
     171            } elseif ( 'public' !== $group->status || ! groups_get_groupmeta( $group->id, 'invite_status' ) ) {
    172172                $response = array(
    173173                    'feedback' => $errors['cannot'],
Note: See TracChangeset for help on using the changeset viewer.