Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/27/2024 07:30:17 PM (2 years ago)
Author:
imath
Message:

Groups: improve the way BuddyPress handles public group invites

  • In bp_group_join_button(): use specific arguments in case a user has been invited to join a public group to generate the action button.
  • In BP Legacy, update the bp_legacy_theme_ajax_joinleave_group() ajax callback to move the group request capability check at the right place & remove a wrong extra check about the invite approvement case.

Fixes #9054
Closes https://github.com/buddypress/buddypress/pull/292

File:
1 edited

Legend:

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

    r13844 r13876  
    34733473         *
    34743474         * @since 11.0.0
     3475         * @since 14.0.0 Handles the case when a user has an invite to join a public group.
    34753476         *
    34763477         * @param BP_Groups_Group $group The group object.
     
    35343535
    35353536                                case 'public':
    3536                                         $url = wp_nonce_url(
    3537                                                 bp_get_group_url(
    3538                                                         $group,
    3539                                                         bp_groups_get_path_chunks( array( 'join' ) )
    3540                                                 ),
    3541                                                 'groups_join_group'
    3542                                         );
    3543 
    3544                                         $button_args = array(
    3545                                                 'id'                => 'join_group',
    3546                                                 'component'         => 'groups',
    3547                                                 'must_be_logged_in' => true,
    3548                                                 'block_self'        => false,
    3549                                                 'wrapper_class'     => 'group-button ' . $group->status,
    3550                                                 'wrapper_id'        => 'groupbutton-' . $group->id,
    3551                                                 'link_href'         => $url,
    3552                                                 'link_text'         => __( 'Join Group', 'buddypress' ),
    3553                                                 'link_title'        => __( 'Join Group', 'buddypress' ),
    3554                                                 'link_class'        => 'group-button join-group',
    3555                                         );
     3537
     3538                                        // Member has outstanding invitation -
     3539                                        // show an "Accept Invitation" button.
     3540                                        if ( $group->is_invited ) {
     3541                                                $url = add_query_arg( 'redirect_to', bp_get_group_url( $group ), bp_get_group_accept_invite_link( $group ) );
     3542
     3543                                                $button_args = array(
     3544                                                        'id'                => 'accept_invite',
     3545                                                        'component'         => 'groups',
     3546                                                        'must_be_logged_in' => true,
     3547                                                        'block_self'        => false,
     3548                                                        'wrapper_class'     => 'group-button ' . $group->status,
     3549                                                        'wrapper_id'        => 'groupbutton-' . $group->id,
     3550                                                        'link_href'         => $url,
     3551                                                        'link_text'         => __( 'Accept Invitation', 'buddypress' ),
     3552                                                        'link_title'        => __( 'Accept Invitation', 'buddypress' ),
     3553                                                        'link_class'        => 'group-button accept-invite',
     3554                                                );
     3555
     3556                                                // Member has no outstanding invitation -
     3557                                                // show a "Join Group" button.
     3558                                        } else {
     3559                                                $url = wp_nonce_url(
     3560                                                        bp_get_group_url(
     3561                                                                $group,
     3562                                                                bp_groups_get_path_chunks( array( 'join' ) )
     3563                                                        ),
     3564                                                        'groups_join_group'
     3565                                                );
     3566
     3567                                                $button_args = array(
     3568                                                        'id'                => 'join_group',
     3569                                                        'component'         => 'groups',
     3570                                                        'must_be_logged_in' => true,
     3571                                                        'block_self'        => false,
     3572                                                        'wrapper_class'     => 'group-button ' . $group->status,
     3573                                                        'wrapper_id'        => 'groupbutton-' . $group->id,
     3574                                                        'link_href'         => $url,
     3575                                                        'link_text'         => __( 'Join Group', 'buddypress' ),
     3576                                                        'link_title'        => __( 'Join Group', 'buddypress' ),
     3577                                                        'link_class'        => 'group-button join-group',
     3578                                                );
     3579                                        }
     3580
    35563581                                        break;
    35573582
     
    35743599                                                );
    35753600
    3576                                         // Member has requested membership but request is pending -
    3577                                         // show a "Request Sent" button.
     3601                                                // Member has requested membership but request is pending -
     3602                                                // show a "Request Sent" button.
    35783603                                        } elseif ( $group->is_pending ) {
    35793604                                                $button_args = array(
     
    35903615                                                );
    35913616
    3592                                         // Member has not requested membership yet -
    3593                                         // show a "Request Membership" button.
     3617                                                // Member has not requested membership yet -
     3618                                                // show a "Request Membership" button.
    35943619                                        } else {
    35953620                                                $url = wp_nonce_url(
Note: See TracChangeset for help on using the changeset viewer.