Customizing, Enabling/Disabling Upload/Add from Web feature of gallery

BP Gallery provides a filter “bp_gallery_is_method_enabled” which allows you to enable/disable the upload/add from web method and It can be customized to be enabled for a particular gallery type, or particular user roles or for a particular user/gallery. I will explain it with a few examples below

Filter: bp_gallery_is_method_enabled

It passes 3 arguments to the called function in order:-

  • $is_enabled: default value for whether the method is enabled or not
  • $method: It is actually the name of method, possible values [“upload”,”add_from_web”]
  • $gallery: The current gallery in perspective, It isĀ  a $gallery object

Based on the above daya, your custom function can return true/false to customize the apperance of upload/add_from_web.

Sample usage:-


In the above example, “your_custom_enable_disable_method” is the name of method which will be called. 10, is the priority of the the method being call, you can change it to anything depending on your condition. “3” is the number of arguments, the function will be passed and is very important that you specify it.

A sample function definition will look like this

function your_custom_enable_disable_method($is_enabled,$method,$gallery){

//do something

//return true/false [false to disable, true to enable]



Disable Upload and keep add from web only feature:-

//disable upload for video gallery
function bp_gallery_disable_upload_method($is_enabled,$method,$gallery){

return false;
return $is_enabled;

The above code will disable upload completely.

Disable upload for one of the gallery type, say video gallery

//disable upload for video gallery
function bp_gallery_disable_upload_for_video_gallery($is_enabled,$method,$gallery){

if($method=="upload"&&$gallery->gallery_type=="video")//you may change it to "audio"/"photo" to disable upload on audio or photo gallery
return false;
return $is_enabled;

Disable add from web completely

//disable upload for video gallery
function bp_gallery_disable_add_from_web($is_enabled,$method,$gallery){

return false;
return $is_enabled;

The above code will disable the add from web feature completely.

Disable add from web for a particular gallery type

//disable upload for photo gallery
function bp_gallery_disable_add_from_web_for_photo_gallery($is_enabled,$method,$gallery){

if($method=="add_from_web"&&$gallery->gallery_type=="photo")//you may change it to "audio"/"video" to disable upload on audio or photo gallery
return false;
return $is_enabled;

The above code will disable the add from web method for the photo gallery.

Similarly, you can extend it to any level, say you can disable the upload/add from web method for a particular user/ users with particular role or just for a specific gallery. So, the possibilities are unlimited and now It’s all upto you to use your imagination/need in consideration and do the job.