BP_REST_Groups_Endpoint::bp_rest_user_can_join( BP_Groups_Group $item )
Check the group join with members type.
Description
Parameters
- $item
-
(Required) Group object.
Return
(bool)
Source
File: bp-groups/classes/class-bp-rest-groups-endpoint.php
protected function bp_rest_user_can_join( $item ) { $user_id = get_current_user_id(); if ( empty( $user_id ) ) { return false; } if ( 'public' === bp_get_group_status( $item ) ) { return true; } // Check for the group type > profile type joining. if ( function_exists( 'bp_member_type_enable_disable' ) && true === bp_member_type_enable_disable() && function_exists( 'bp_disable_group_type_creation' ) && true === bp_disable_group_type_creation() ) { $group_type = bp_groups_get_group_type( $item->id ); $group_type_id = bp_group_get_group_type_id( $group_type ); $get_selected_member_type_join = get_post_meta( $group_type_id, '_bp_group_type_enabled_member_type_join', true ); $get_requesting_user_member_type = bp_get_member_type( $user_id ); if ( is_array( $get_selected_member_type_join ) && in_array( $get_requesting_user_member_type, $get_selected_member_type_join, true ) ) { return true; } } return false; }
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.