• Resolved mikeliius12

    (@mikeliius12)


    Hello,

    Is it possible to make a restriction for the users to upload file only once, or to be displayed only once, or to make it, so users can upload only one file.

    THanks

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

    (@nickboss)

    Both options can be done using the plugin’s filters. What do you prefer?

    Regards

    Nickolas

    Thread Starter mikeliius12

    (@mikeliius12)

    Hi Nickolas,

    Thanks for the answer,
    Well the best case scenario would be for the users to be able to upload file only once, and then on the upload field to have a text that they have already uploaded the file.

    BR

    Plugin Author nickboss

    (@nickboss)

    Do you want the whole upload form to be replaced by a text?

    Nickolas

    Thread Starter mikeliius12

    (@mikeliius12)

    Either text, or the button for upload to be disabled or something.

    thanks

    Plugin Author nickboss

    (@nickboss)

    Ok here is the code:

    global $WFU_MAX_FILES, $WFU_ERROR_MESSAGE;
    $WFU_MAX_FILES = 1;
    $WFU_ERROR_MESSAGE = "You are not allowed to upload any more files.";
    if (!function_exists('wfu_file_upload_output_handler')) {
    	function wfu_file_upload_output_handler($output, $params) {
    		global $WFU_MAX_FILES, $WFU_ERROR_MESSAGE;
    		$user = wp_get_current_user();
    		if ( $user->ID > 0 ) {
    			$recs = wfu_get_recs_of_user($user->ID);
    			if ( count($recs) >= $WFU_MAX_FILES )
    				$output = $WFU_ERROR_MESSAGE;
    		}
    		return $output;
    	}
    	add_filter('_wfu_file_upload_output', 'wfu_file_upload_output_handler', 10, 2);
    }

    You need to put it at the end of functions.php file ofyour theme. When maximum number of uploaded files is exceeded (1 in your case), the upload form will be substituted by error message.

    Regards

    Nickolas

    Thread Starter mikeliius12

    (@mikeliius12)

    It works.
    Thank you very much Nickolas

    Plugin Author nickboss

    (@nickboss)

    Ok I am glad.

    Regards

    Nickolas

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Upload only once’ is closed to new replies.