Skip to content

Instantly share code, notes, and snippets.

@gabrielmerovingi
Created February 11, 2015 16:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gabrielmerovingi/db1661919b4679eb1917 to your computer and use it in GitHub Desktop.
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.
/**
* 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