Advertisement
Aurangajeb

Limit File Upload Size for Vendors

Aug 26th, 2021
1,265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.40 KB | None | 0 0
  1. #-- Limit File Upload Size for Vendors --#
  2. function limit_file_upload_size_for_vendors( $limit ) {
  3.  
  4.   $user_id    = get_current_user_id();
  5.   $user_meta  = get_userdata( $user_id );
  6.   $user_roles = $user_meta->roles;
  7.  
  8.   if ( in_array( 'seller', $user_roles ) ) {
  9.     $limit = 2 * 1000000; // 2MB
  10.   }
  11.   return $limit;
  12. }
  13.  
  14. add_filter( 'upload_size_limit', 'limit_file_upload_size_for_vendors' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement