Created
August 6, 2020 21:23
-
-
Save KaineLabs/6ec15f35674a3bc2af876c50a98d2d41 to your computer and use it in GitHub Desktop.
Restrict Joining More Than One Group
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Restrict Joining More Than One Group | |
*/ | |
function yz_restrict_group_join( $button, $group ) { | |
global $bp; | |
if ( current_user_can( 'manage_options' ) || $group->is_member ) { | |
return $button; | |
} | |
$membership_total = count( BP_Groups_Member::get_membership_ids_for_user( $bp->loggedin_user->id ) ); | |
if ( $membership_total >= 1 ) { | |
return false; | |
} | |
return $button; | |
} | |
add_filter( 'bp_get_group_join_button', 'yz_restrict_group_join', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment