• Resolved supernova42

    (@supernova42)


    In the Image Expansion Kit I can specify the maximum number of files that a user can upload. I have a few levels of membership on my site and I would like to have say 3 files max upload for a Standard Membership and 10 files max upload for a Premier Membership.

    Is this possible?

    Thanks

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author xnau webdesign

    (@xnau)

    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.

    Thread Starter supernova42

    (@supernova42)

    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

    Plugin Author xnau webdesign

    (@xnau)

    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

    Thread Starter supernova42

    (@supernova42)

    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

    Plugin Author xnau webdesign

    (@xnau)

    You need to use a single = to assign the value, you have 2.

    Thread Starter supernova42

    (@supernova42)

    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');
    Plugin Author xnau webdesign

    (@xnau)

    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');
    Thread Starter supernova42

    (@supernova42)

    Wonderful, works a treat. I can now set different file upload levels for users.

    Many Thanks

    Thread Starter supernova42

    (@supernova42)

    Meant to close it

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Max Image upload for different users’ is closed to new replies.