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

    (@nickboss)

    Hi, yes it can be done with a plugin hook. Here is an example:

    if (!function_exists('wfu_before_upload_handler')) {
    	function wfu_before_upload_handler($changable_data, $additional_data) {
    		$limit = 1;
    		$user = wp_get_current_user();
    		if ( $user->ID != 0 ) {
    			$filerecs = wfu_get_recs_of_user($user->ID);
    			if ( count($filerecs) >= $limit )
    				$changable_data["error_message"] = "File rejected. Maximum upload limit reached.";
    		}
    		return $changable_data;
    	}
    	add_filter('wfu_before_upload', 'wfu_before_upload_handler', 10, 2);
    }

    Set $limit to the value you want. I a user tries to upload more files, an error message will be shown.

    You need to put it in functions.php file of your theme.

    Regards

    Nickolas

    Thread Starter tanazius

    (@tanazius)

    Thank you Nickolas, works like a charm!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Limit the files for an user’ is closed to new replies.