• Resolved Delia Carballo

    (@soydelia)


    Hello,

    I have configured the plugin as you explanined in this post https://www.ads-software.com/support/topic/change-filename/

    Now I would like to know if I could do the same but using “email” instead of “username”.

    As example, file name now is username-option1.* if user select “option1” and I would like the file name be useremail-option1.*

    Is that possible?

    And is it possible to use the user email to name the folder? Instead of username. Something like %email% instead of %username%.

    Thanks!

Viewing 1 replies (of 1 total)
  • Plugin Author nickboss

    (@nickboss)

    Hi, here is an updated code for what you ask:

    if (!function_exists('wfu_before_file_check_handler')) {
    	function wfu_before_file_check_handler($changable_data, $additional_data) {
    		$user = get_userdata($additional_data["user_id"]);
    		if ( $user != false ) {
    			$filepath = wfu_basedir($changable_data["file_path"]);
    			$usermail = $user->user_email;
    			$filepath = str_replace("%useremail%", $usermail, $filepath);
    			$new_filename = $changable_data["user_data"][0]["value"];
    			$fileext = wfu_fileext($changable_data["file_path"], true);
    			$changable_data["file_path"] = $filepath.$usermail."-".$new_filename.$fileext;
    		}
    		return $changable_data;
    	}
    	add_filter('wfu_before_file_check', 'wfu_before_file_check_handler', 10, 2); 
    }

    It will replace username with user’s email in the filename. If you add %useremail% in the path, it will also be replaced by the user’s email.

    Regards

    Nickolas

Viewing 1 replies (of 1 total)
  • The topic ‘Change filename using email’ is closed to new replies.