There is a filter
pdb-{$fieldname}_maxfiles
that you can use to set the maximum number of uploads at runtime…in other words, if someone is logged in, you can use that filter to change the number of allowed uploads.
I can’t see how to use this filter Roland. I’ve used it in my shortcode but with no effect. I’ve also created a field in my database called ‘maximum_files’.
<?php
$maximum_files=’7′;
echo do_shortcode(‘[pdb_record filter=pdb-{$maximum_files}_maxfiles fields=”photo_library” record_id=’.$user_id.’]’);
Thanks
Sorry, not a shortcode filter, this is a filter you will need to write a handler for. It passes in the global setting, your handler need to return the limit you want to set at that time.
for example, if the field name is “photo_gallery” then your filter will be:
pdb-photo_gallery_maxfiles
General info on using WordPress filters: apply_filters
I have a field called ‘photo_library’ which is defined as a ‘Multi Image Upload’.
I have set my default value of maximum files to upload as 5.
This is my function, but it doesn’t work. It won’t let me upload more than 5 files.
// filter hook - pdb-photo_library_maxfiles
function change_max_files($files) {
$files=='7';
return $files;
}
add_filter('pdb-photo_library_maxfiles','change_max_files');
Many thanks
You need to use a single = to assign the value, you have 2.
Changed that to a single = sign but still doesn’t work.
function change_max_files($files) {
$files='7';
return $files;
}
add_filter('pdb-photo_library_maxfiles','change_max_files');
OK, I’m sorry, I got it wrong…the filter is supposed to use the name of the form element, not the name of the field. So the filter should be:
pdb-multi-image-upload_maxfiles
so like this:
function change_max_files($files) {
$files='7';
return $files;
}
add_filter('pdb-multi-image-upload_maxfiles','change_max_files');
Wonderful, works a treat. I can now set different file upload levels for users.
Many Thanks