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!



Ragnar 6:07 pm on May 22, 2009 Permalink |
Thanks a lot, dude. Prolly can put it to use, too, now. ^^
Ragnar 6:19 pm on May 22, 2009 Permalink |
Ah, what the hell… after adding all that my admin gives me a blank page. :S
Ragnar 6:29 pm on May 22, 2009 Permalink |
Okay, never mind, I got my admin page back… but the code doesn’t seem to work… added all these new thing right where supposed to but TDO still uploads it to some id folder.
Ragnar 6:48 pm on May 22, 2009 Permalink |
4th comment here, hello!
Sorry, but got it working fine, everything is perfect, I just messed up stuff myself. Thanks a lot for this great tutorial!
Derek 8:56 pm on June 2, 2009 Permalink |
I have had great success with TDO Mini Forms and your mini hacks have been of tremendous help. One thing I am seeking is how to use TDO Mini Forms with video options. Wondered if you might had an ideas on what I may be able to try.
Thanks!!
Tim 2:55 pm on November 10, 2009 Permalink |
People who want to use this (for example) when using a post form for unregistered users: be careful!
If the post is rejected (deleted) by an administrator (at the ‘moderation’), the whole folder of that specific month is emptied… see what I’m saying? Careful.
Just a tip. Good hack though!
admin 10:48 pm on November 10, 2009 Permalink |
Tim, thanks for the warning…I wasn’t aware of this, obliviously.
I’ll test this and implement your suggestion and will come back to you…
admin 10:58 pm on November 10, 2009 Permalink |
Shit…you’re right,I’m seeing it only now: at http://fan-tas-tic.com, where I implemented the hack, I’ve already deleted all other images in the same folder with the one I only wanted to delete!
Thanks for the warning…
Tim 1:53 am on November 11, 2009 Permalink |
No problem!
Tim 3:25 pm on November 10, 2009 Permalink |
Suggestion in this case
$postdir = $options['path'].$yearID.DIRECTORY_SEPARATOR.$monthID.DIRECTORY_SEPARATOR.$post_ID;
iqbal 5:44 pm on December 6, 2009 Permalink |
hii…every one…i just wanna ask how to make a submission form like for sample…downarchive.com…that another or registered users can submit their download to our site??
can we hack TDO mini Form tobe like it??
sorry for my bad english…
thanks for helping…
AZIndex: sort groupheader URL 3:03 pm on February 12, 2010 Permalink |
[...] the TDO mini form plugin the AZIndex is an incredible powerful plugin…but also lacks a certain feature, which would [...]
Tschai 7:42 pm on May 22, 2009 Permalink |
Glad to hear it’s working and thanks for letting know…
Tschai 8:33 am on June 4, 2009 Permalink |
Do you want to upload these video files to your own server or do you just want to refer to some external (youtube, vimeo) URL’s?
The latter should be very easy.
The first option might require some hacking…
Derek 5:27 pm on June 4, 2009 Permalink |
I was attempting to upload vids to my own server and then embed them in a post.
That’s where I am having the problem, videos upload fine just can’t get them to display.
Tschai 8:11 am on June 5, 2009 Permalink |
If you’re able to upload the video and retrieve the URL generated by TDO forms, than from here your problem is a general issue and not TDO mini form related anymore.
You probably need the right plugin to show the video, depending on the format of your video.
Have you tried something like this one http://wordpress.org/extend/plugins/embedded-video-with-link/, which seems to support almost any format? If you’re able getting the full URL/path, this should do the trick for you…