• Hi

    If filename was broken when it contains non-English.

    How to make filename like ‘date + username’?
    How to allow upload only authenticated users?

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

    (@nickboss)

    Hi, I answered the first question by email.

    Regarding the second one, it is very easy. The plugin has an option for this. Using the visual editor of the plugin, go to Main tab, locate option “Upload Roles” and uncheck “Include Guests”.

    Regards

    Nickolas

    Thread Starter carrotis

    (@carrotis)

    I didn’t get email from you.

    Please let me know how to change filename with datetime + userid.

    I tried to do this url (https://www.iptanus.com/use-filters-actions-wordpress-file-upload-plugin/) but it was not work.

    Plugin Author nickboss

    (@nickboss)

    Hi, I suppose you have the Pro version, right?

    Here are instructions:

    1. Go to Dashboard / Settings / WordPress File Upload / Hooks and add a new hook.
    2. Give it any title you want.
    3. Put the following code in the Code box:

    
    if (!function_exists('wfu_before_file_check_handler')) {
    	function wfu_before_file_check_handler($changable_data, $additional_data) {
    		$fullpath = $changable_data["file_path"];
    		$onlypath = wfu_basedir($fullpath);
    		$filename = wfu_basename($fullpath);
    		$fileext = wfu_fileext($filename, true);
    		$username = "unknown";
    		$user = get_userdata($additional_data["user_id"]);
    		if ( $user != false ) $username = $user->user_login;
    		$filename = date("Y-m-d-H-i-s", time())."-".$username.$fileext;
    		$changable_data["file_path"] = $onlypath.$filename;
    		return $changable_data;
    	}
    	add_filter('wfu_before_file_check', 'wfu_before_file_check_handler', 10, 2); 
    }
    

    4. Set Status to Active and Save.

    The above will rename the filename to the format “YYYY-MM-DD-hh-mm-ss-username”.

    Regards

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Change upload filename’ is closed to new replies.