• Resolved rsl89

    (@rsl89)


    Hello everyone.
    How I do limit the download of a digital product for sellers? For example, I want to limit downloads to 10 MB

Viewing 9 replies - 1 through 9 (of 9 total)
  • Just my suggestion, but couldn’t you just limit the upload limit with PHP on your server?

    Thread Starter rsl89

    (@rsl89)

    Then the download limit will be applied to everyone, even to admins and to the script itself.

    ahh I see – you want per vendor limits.

    Good feature suggestion ??

    Plugin Support Jahidul Hassan Mojumder

    (@jahidulhassan)

    Hi @rsl89

    Right now Dokan does not have a feature to limit a vendor’s download of a digital product by default. This will require proper customization.

    Thanks!

    Thread Starter rsl89

    (@rsl89)

    Help with the code

    if ( is_user_logged_in() ) {
    
        if (current_user_can('vendor')) {
    
            function PBP_increase_upload( $bytes )
    
            {
    
                return 10485760; // 100 МБ
    
            }
            add_filter( 'upload_size_limit', 'PBP_increase_upload' );
    
        }
    
    }
    Thread Starter rsl89

    (@rsl89)

    Help please

    Thread Starter rsl89

    (@rsl89)

    ?

    Hi @rsl89,

    Vendors don’t download a digital product. Digital products’ downloadable files are downloaded by customers.

    If you want them to download a limited-sized file, you need to upload a limited file size too.

    However, if you want to limit the upload file size for vendors, you can add the following snippet at the bottom of your child theme’s functions.php file.

    #-- Limit File Upload Size for Vendors --#
    function limit_file_upload_size_for_vendors( $limit ) {
    
      $user_id    = get_current_user_id();
      $user_meta  = get_userdata($user_id);
      $user_roles = $user_meta->roles;
    
      if ( in_array( 'seller', $user_roles ) ) {
        $limit = 2 * 1000000; // 2MB
      }
    
      return $limit;
    }
     
    add_filter( 'upload_size_limit', 'limit_file_upload_size_for_vendors' );

    Thank you!

    Thread Starter rsl89

    (@rsl89)

    Thanks!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Limit downloads’ is closed to new replies.