• Resolved TWD

    (@twd)


    function filter_site_upload_size_limit( $size ) {
        // Set the upload size limit to 100KB for users lacking the 'manage_options' capability.
        if ( ! current_user_can( 'manage_options' ) ) {
            
            // 100KB
            $size = 100;
        }
        return $size;
    }
    add_filter( 'upload_size_limit', 'filter_site_upload_size_limit', 20 );

    I tested with a 386KB image file and it still accepted without any error message.
    I was logged out at the time.

    Taken from here:
    https://developer.wordpress.org/reference/hooks/upload_size_limit/

    • This topic was modified 7 years, 10 months ago by TWD.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor christiechirinos

    (@christiechirinos)

    Hi TWD,

    Just so you know, you may get help from the power users that browse this forum, but our support at Caldera WP doesn’t generally cover doing reviews for customizations of our products. However, we have set up multiple resources available that can point you in the right direction:

    On the documentation page for any of our hooks, for example this one https://calderaforms.com/doc/caldera_forms_render_get_field/, there is a panel at the end with the header “Where Does This Code Go?” That gives you links to introductory articles about what WordPress hooks are, why you use them and how to use them. It may be worthwhile to review these to make sure your code is somewhere where it will work with Caldera Forms.

    Caldera Forming is our community forum. As a part of this community, you can ask fellow Caldera Forms users for help with custom code and design. https://www.facebook.com/groups/651862761663883

    If you’re looking for comprehensive assistance in developing your site (as opposed to small code modifications), or if you’d rather leave the customization to the professionals, consider reaching out to someone from our list of recommended developers: https://calderaforms.com/recommended-developers/.

    Visit our developer documentation for tutorials and troubleshooting help. https://calderaforms.com/category/developer-api/

    If you’re adding code from a third-party source, we recommend reaching out to the source for help.

    Thread Starter TWD

    (@twd)

    This works fine in terms of vetting the file size:

    //Limit file upload size to 1MB (only works for Advanced file uploader)
    function increase_upload_size_limit( $limit ) {
      return 1048576;
    }
    add_filter( 'upload_size_limit', 'increase_upload_size_limit' );
    

    HOWEVER the Advanced File Uploader DOESNT WORK… PERIOD.

    Even without any functions.php custom code, all other plugins disabled, the form just doesn’t send.

    Any advice?

    • This reply was modified 7 years, 10 months ago by TWD.
    • This reply was modified 7 years, 10 months ago by TWD.
    Thread Starter TWD

    (@twd)

    fyi Facebook Caldera Group has accepted ZERO new members in last 30 days.
    Appears that the Admins are busy elsewhere. 🙁

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Why doesn’t this code limit the file upload size?’ is closed to new replies.