Skip to:
Content

BuddyPress.org

Ticket #8359: 8359.patch

File 8359.patch, 3.4 KB (added by imath, 15 months ago)
  • src/bp-groups/bp-groups-notifications.php

    diff --git src/bp-groups/bp-groups-notifications.php src/bp-groups/bp-groups-notifications.php
    index 4fd15a023..ebe99d8b0 100644
    function groups_notification_new_membership_request( $requesting_user_id = 0, $a 
    151151                'user_id'    => $requesting_user_id,
    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
    158163        $group = groups_get_group( $group_id );
  • src/bp-groups/screens/single/request-membership.php

    diff --git src/bp-groups/screens/single/request-membership.php src/bp-groups/screens/single/request-membership.php
    index 293055766..7e8886eec 100644
     
    1414 */
    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        }
    3337
    function groups_screen_group_request_membership() { 
    3539        if ( isset( $_POST['group-request-send']) ) {
    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                }
     45
     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                }
    4056
    41                 if ( !groups_send_membership_request( [ 'user_id' => bp_loggedin_user_id(), 'group_id' => $bp->groups->current_group->id ] ) ) {
     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 {
    4460                        bp_core_add_message( __( 'Your membership request was sent to the group administrator successfully. You will be notified when the group administrator responds to your request.', 'buddypress' ) );
    function groups_screen_group_request_membership() { 
    6379         * @param string $value Path to a group's Request Membership template.
    6480         */
    6581        bp_core_load_template( apply_filters( 'groups_template_group_request_membership', 'groups/single/home' ) );
    66 }
    67  No newline at end of file
     82}