TDO Mini Forms: upload path/URL mini hack

The TDO Mini Forms Wordpress Plugin is simply one of these plugins you’ll end up using, when you’ll be using WordPress for more than ‘just another blog’.

For my upcoming project I was looking for a fully customizable end user form and after having tried a bunch, TDO mini forms was simply the best.
I still don’t understand why it is called ‘mini’ because it has a ton of options and almost all of them very useful.

The only issue I got with it was with the file/image upload widget: It was putting the uploaded files in wp-content/uploads/subfolder where I wanted them in wp-content/uploads/year/month.

Although there are usefull hints in the support forum, they wont get you there exactly. So here is the hack to solve this issue:
In the plugins folder replace line 552 (up until the line “// store info about files on post”) in file tdomf-upload-functions.php from this

$postdir = $options['path'].DIRECTORY_SEPARATOR.$post_ID;

to this

$yearID=date("Y");
$monthID=date("m");

$postdir = $options['path'].$yearID.DIRECTORY_SEPARATOR.$monthID;
$postdir2 = $options['url'].$yearID."/".$monthID;

tdomf_recursive_mkdir($postdir,TDOMF_UPLOAD_PERMS);
tdomf_recursive_mkdir($postdir2,TDOMF_UPLOAD_PERMS);
$newpath = $postdir.DIRECTORY_SEPARATOR.$theirfiles[$i]['name'];
$newpath2 = $postdir2.DIRECTORY_SEPARATOR.$theirfiles[$i]['name'];

if(rename($theirfiles[$i]['path'], $newpath)) {

        $newpath = realpath($newpath);
        $newpath2 = realpath($newpath2);

Note that a variable 2 is added, just after the original.
Also note, that I’ve replaced the variable DIRECTORY_SEPARATOR in $postdir2 into “/”, cause it was giving me headaches.

In line 564 in the same file add just beneath this line

add_post_meta($post_ID,TDOMF_KEY_DOWNLOAD_PATH.$i, $wpdb->escape($newpath),true);

the following

add_post_meta($post_ID,ftt_path,$postdir2,true);

Make sure you do use $postdir2 here again. Will be using ftt_path to retrieve the stored URL, so remember what name you give it here.

And now we’ll be calling the uploaded files via the URL like this

get_post_meta($post->ID, "ftt_path",true);

instead of this, which will give you only the absolute path

get_post_meta($post->ID, "_tdomf_download_name_0",true);

This way it’s not even necessary to check ‘Organize my uploads into month- and year-based folders’ at your Miscellaneous Settings.

Hope this helps others out also. If you have any other issues with TDO Mini forms, please refer to the original support form.

UPGRADE warnings

Remember that automatically upgrading the plugin to the newest version will overwrite the hacks above…so make sure to actually backup before you upgrade!