BuddyDev

Limiting Number of galleries per user

You can limit the no,. of galleries a user can create in bp-gallery.
here is a sample code
[sourcecode language="php"]

add_filter("user_can_create_gallery","limit_gallery_count_for_user",15,3);
function limit_gallery_count_for_user($can_create,$owner_type,$owner_id){
    global $bp;

  if($owner_type!="user")
      return $can_create;//do not handle for other components
if(empty($_POST['component_id']))
return $can_create;//do not handle if this is not the gallery create action
//if we are here, we are going to create a gallery for user
//check if gallery allowed or not

if(gallery_count_available_for_user( $owner_id,null))//replace null with $_POST["gallery_type"] if you want to restrict 1 gallery for each gallery type for user
     return $can_create; //if user has permission, do not change it
else
    return false; //deny the permission if the count exceeded
}

function gallery_count_available_for_user($user_id,$type){
$gallery_count=BP_Gallery_Gallery::get_gallery_count_by_type($type, "user", $user_id, null);
//how many to allow
$allowed_count=5;//only 5 galleries in total change it with your number
if($gallery_count<=$allowed_count)
return true;//if there does not exist a gallery of this type allow to create 

return false;
}

[/sourcecode]