Reply To: allow members to join only 1 group
This solution is even better because it displays the leave group button, which could be helpful, if you want to restrict users to 1 group only, but be able to leave 1 group and join another….
function action_groups_member_before_save( $array ) {
$user_id = bp_loggedin_user_id();
$result = groups_total_groups_for_user($user_id);
if ( $result > 0 ) {
wp_die('You can only join 1 group ');
}
return $button;
}
add_action( 'groups_member_before_save', 'action_groups_member_before_save', 10, 1 );