• Resolved jlohl

    (@jlohl)


    Hello,
    is it possible to automatically insert date, ie date(“d-m-y”) into upload path ?
    At the moment, I added to the path a user field /%username%/%userdata2% with userdata2 being date. This works but I’d like to have the real date in the path instead of a date choosen by the user.

    Thanks for help.
    JL

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

    (@nickboss)

    Hi, this is not so straightforward. You need some Javascript tweaks. Here is the code below. You need to put it inside the page, right below the shortcode. This code will hide the second date field (so that the user cannot fill it) and it will be populated automatically with the current date.

    
    <script type="text/javascript">
    document.getElementById("userdata_1_1").style.display = "none";
    Code_Initializators[Code_Initializators.length] = function(sid) {
    	var Code_Object = {};
    	Code_Object.pre_start = function () {
    		var d = new Date();
    		document.getElementById("hiddeninput_1_userdata_1").value = ('0'+d.getDate()).slice(-2)+'-'+('0'+(d.getMonth()+1)).slice(-2)+'-'+('0'+d.getFullYear()).slice(-2);
    	}
    	return Code_Object;
    }
    </script>
    

    Regards

    Nickolas

    Thread Starter jlohl

    (@jlohl)

    Thank you Nickolas, it works fine.
    I thought that a simpler solution would be available with some hook.
    Regards
    JL

    • This reply was modified 7 years, 12 months ago by jlohl.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Insert date into upload path’ is closed to new replies.