Support » Plugin: WordPress File Upload » file size notification

  • Resolved omako san

    (@omako)


    I was just wondering if there is a way to notify a user per email about file size of an uploaded file? the “email body” within the notificaion section of your plugins control panel doesn’t give me that option. regards marcus

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

    (@nickboss)

    Hi, put the following script at the end of functions.php file of your theme:

    if (!function_exists('wfu_before_email_notification_handler')) {
    	function wfu_before_email_notification_handler($changable_data, $additional_data) {
    		$files = explode(",", $changable_data["filepath"]);
    		$sizes = array();
    		foreach ( $files as $file ) array_push($sizes, filesize(trim($file)));
    		$changable_data["message"] = str_replace("%size%", implode(",", $sizes), $changable_data["message"]);
    		return $changable_data;
    	}
    	add_filter('wfu_before_email_notification', 'wfu_before_email_notification_handler', 10, 2); 
    }

    The put the variable %size% inside the email. It will be replaced by the size of the uploaded file.

    Regards

    Nickolas

    hmm, this causes a fatal error on my site

    Plugin Author nickboss

    (@nickboss)

    This means that it was not added correctly (I tested the hook for errors).

    If functions.php file ends with ?> symbol, the code must be put above that symbol.

    Nickolas

    Thank you. I figured it out. Another Plugin caused the Error. Is is possible to show more human readable numbers, like KB oder MB? Sorry to bother you … Best Marcus

    Plugin Author nickboss

    (@nickboss)

    Sure, replace the script with the following:

    if (!function_exists('wfu_before_email_notification_handler')) {
    	function wfu_before_email_notification_handler($changable_data, $additional_data) {
    		$files = explode(",", $changable_data["filepath"]);
    		$sizes = array();
    		foreach ( $files as $file ) array_push($sizes, wfu_human_filesize(filesize(trim($file))));
    		$changable_data["message"] = str_replace("%size%", implode(",", $sizes), $changable_data["message"]);
    		return $changable_data;
    	}
    	add_filter('wfu_before_email_notification', 'wfu_before_email_notification_handler', 10, 2); 
    }

    Regards

    Nickolas

    Yes! Thank you 🙂

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.