Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author nickboss

    (@nickboss)

    marking as resolved since it was addressed in a private conversation

    Hello,
    it could be interesting for some users to know how this limitation of uploads was done.
    Would you agree to share the solution ?

    Thanks a lot
    JL

    Plugin Author nickboss

    (@nickboss)

    Hi, here is the code, which you need to put at the end of functions.php (for Free version):

    
    if (!function_exists('wfu_before_file_check_handler')) {
    	function wfu_before_file_check_handler($changable_data, $additional_data) {
    		$user_limit = array();
    		$generic_limit = 20;
    		$user_limit["nickboss"] = 10;
    		$user_limit["john"] = 5;
    		$user = get_userdata($additional_data["user_id"]);
    		if ( $user != false ) {
    			$limit = $generic_limit;
    			if ( isset($user_limit[$user->user_login]) ) $limit = $user_limit[$user->user_login];
    			$filerecs = wfu_get_recs_of_user($additional_data["user_id"]);
    			if ( count($filerecs) >= $limit )
    				$changable_data["error_message"] = "File rejected. Maximum upload limit reached.";
    		}
    		return $changable_data;
    	}
    	add_filter('wfu_before_file_check', 'wfu_before_file_check_handler', 10, 2); 
    }
    

    The $generic_limit variable hold the generic limit for all users. If you do not want a generic limit, then give it a big number (e.g. 1000000).
    The $user_limit array holds specific limits per user. Here I have added as an example a limit for user nickboss to be 10 and for john to be 5. You can add more users by adding more lines.

    Regards

    Nickolas

    Thank you Nickolas, support is allways top for this File Upload plugin !

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Limit number of uploads per user’ is closed to new replies.