Created
February 11, 2015 16:33
-
-
Save gabrielmerovingi/db1661919b4679eb1917 to your computer and use it in GitHub Desktop.
Will only allow users with more then 5000 myCRED points to create groups in BuddyPress.
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
/** | |
* Limit BP Group Creation | |
* Only users with x amount of points can create groups. | |
* @version 1.0 | |
*/ | |
add_filter( 'bp_user_can_create_groups', 'mycred_pro_limit_bp_group_creation' ); | |
function mycred_pro_limit_bp_group_creation( $can ) { | |
if ( ! function_exists( 'mycred' ) ) return $can; | |
$point_type = 'mycred_default'; | |
$mycred = mycred( $point_type ); | |
$user_id = get_current_user_id(); | |
// If excluded | |
if ( $mycred->exclude_user( $user_id ) ) return $can; | |
// Point requirement | |
$required = 5000; | |
// Decline if balance is lower then required | |
if ( $mycred->get_users_balance( $user_id, $point_type ) < $required ) return false; | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment