Skip to:
Content

BuddyPress.org

Changeset 12720


Ignore:
Timestamp:
09/13/2020 07:01:51 PM (15 months ago)
Author:
imath
Message:

Make sure Group membership requests includes the optional message

When implementing the BP Invitations feature in 6.0.0, we forgot to set the content argument of the array passed to groups_send_membership_request()` function with the optional message content.

Props scipi

Fixes #8359 (6.0 branch)

Location:
branches/6.0/src/bp-groups
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/6.0/src/bp-groups/bp-groups-notifications.php

    r12590 r12720  
    152152        'item_id'    => $group_id,
    153153    ) );
     154
    154155    if ( $requests ) {
    155156        $request_message = current( $requests )->content;
     157
     158        if ( $request_message ) {
     159            $request_message = "\n" . $request_message . "\n";
     160        }
    156161    }
    157162
  • branches/6.0/src/bp-groups/screens/single/request-membership.php

    r12671 r12720  
    1515function groups_screen_group_request_membership() {
    1616
    17     if ( !is_user_logged_in() )
     17    if ( ! is_user_logged_in() ) {
    1818        return false;
     19    }
    1920
    2021    $bp = buddypress();
    2122
    22     if ( 'private' != $bp->groups->current_group->status )
     23    if ( 'private' != $bp->groups->current_group->status ) {
    2324        return false;
     25    }
    2426
    2527    // If the user is already invited, accept invitation.
    2628    if ( groups_check_user_has_invite( bp_loggedin_user_id(), $bp->groups->current_group->id ) ) {
    27         if ( groups_accept_invite( bp_loggedin_user_id(), $bp->groups->current_group->id ) )
     29        if ( groups_accept_invite( bp_loggedin_user_id(), $bp->groups->current_group->id ) ) {
    2830            bp_core_add_message( __( 'Group invite accepted', 'buddypress' ) );
    29         else
     31        } else {
    3032            bp_core_add_message( __( 'There was an error accepting the group invitation. Please try again.', 'buddypress' ), 'error' );
     33        }
     34
    3135        bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
    3236    }
     
    3640
    3741        // Check the nonce.
    38         if ( !check_admin_referer( 'groups_request_membership' ) )
     42        if ( ! check_admin_referer( 'groups_request_membership' ) ) {
    3943            return false;
     44        }
    4045
    41         if ( !groups_send_membership_request( [ 'user_id' => bp_loggedin_user_id(), 'group_id' => $bp->groups->current_group->id ] ) ) {
     46        // Default arguments for the membership request.
     47        $request_args = array(
     48            'user_id'  => bp_loggedin_user_id(),
     49            'group_id' => $bp->groups->current_group->id
     50        );
     51
     52        // If the member added a message to their request include it into the request arguments.
     53        if ( isset( $_POST['group-request-membership-comments'] ) && $_POST['group-request-membership-comments'] ) {
     54            $request_args['content'] = strip_tags( wp_unslash( $_POST['group-request-membership-comments'] ) );
     55        }
     56
     57        if ( ! groups_send_membership_request( $request_args ) ) {
    4258            bp_core_add_message( __( 'There was an error sending your group membership request. Please try again.', 'buddypress' ), 'error' );
    4359        } else {
Note: See TracChangeset for help on using the changeset viewer.