Set Media upload limit for Instructors

This Tip is to limit the size of upload media for Non-Administrators.

For example by using this tip you can restrict instructors to upload media file size in courses.

Please paste this code in the wplms-customizer.php file present in your wplms customizer plugin.

 

/**
 * Filter the upload size limit for non-administrators.
 *
 * @param string $size Upload size limit (in bytes).
 * @return int (maybe) Filtered size limit.
 */
function wplms_filter_site_upload_size_limit( $size ) {
    if ( ! current_user_can( 'manage_options' ) ) {
        // 10 MB.
        $size = 1024 * 10000;
    }
    return $size;
}
add_filter( 'upload_size_limit', 'wplms_filter_site_upload_size_limit', 20 );

This tip restricts Non-Administrators to upload media files upto 10mb.

You can change it from 10mb to whatever you want.

For example you want to limit users to upload upto 20 mb then just change

$size = 1024 * 10000;

to

$size = 1024 * 20000;

Leave a Reply

Your email address will not be published. Required fields are marked *