groups_action_join_group()

Catch and process “Join Group” button clicks.

Description

Return

(bool)

Source

File: bp-groups/actions/join.php

16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
function groups_action_join_group() {
 
    if ( !bp_is_single_item() || !bp_is_groups_component() || !bp_is_current_action( 'join' ) )
        return false;
 
    // Nonce check.
    if ( !check_admin_referer( 'groups_join_group' ) )
        return false;
 
    $bp = buddypress();
 
    // Skip if banned or already a member.
    if ( !groups_is_user_member( bp_loggedin_user_id(), $bp->groups->current_group->id ) && !groups_is_user_banned( bp_loggedin_user_id(), $bp->groups->current_group->id ) ) {
 
        // User wants to join a group that requires an invitation to join.
        if ( ! bp_current_user_can( 'groups_join_group', array( 'group_id' => $bp->groups->current_group->id ) ) ) {
            if ( !groups_check_user_has_invite( bp_loggedin_user_id(), $bp->groups->current_group->id ) ) {
                bp_core_add_message( __( 'There was an error joining the group.', 'buddyboss' ), 'error' );
                bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
            }
        }
 
        // User wants to join any group.
        if ( !groups_join_group( $bp->groups->current_group->id ) )
            bp_core_add_message( __( 'There was an error joining the group.', 'buddyboss' ), 'error' );
        else
            bp_core_add_message( __( 'You joined the group!', 'buddyboss' ) );
 
        bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
    }
 
    /**
     * Filters the template to load for the single group screen.
     *
     * @since BuddyPress 1.0.0
     *
     * @param string $value Path to the single group template to load.
     */
    bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) );
}

Changelog

Changelog
Version Description
BuddyPress 1.0.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.