Don't bother looking for the 'social' buttons to share, save or bookmark this post: Leave your feedback in the comments and get the discussion started!

Posted on 22 May '09 \ Categories: blog, develop \ Tags: , , ,

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!

30 Responses to “TDO Mini Forms: upload path/URL mini hack”
  1. Ragnar says:

    Thanks a lot, dude. Prolly can put it to use, too, now. ^^

  2. Ragnar says:

    Ah, what the hell… after adding all that my admin gives me a blank page. :S

  3. Ragnar says:

    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.

  4. Ragnar says:

    4th comment here, hello! :D Sorry, but got it working fine, everything is perfect, I just messed up stuff myself. Thanks a lot for this great tutorial!

  5. Derek says:

    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!!

  6. Tim says:

    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!

  7. Tim says:

    Suggestion in this case

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

  8. iqbal says:

    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…

  9. [...] the TDO mini form plugin the AZIndex is an incredible powerful plugin…but also lacks a certain feature, which would [...]

  10. Martin says:

    Is there any way this could be incorporated with a gallery plugin? Say, the gallery plugin takes the images from the folder specified by tdo mini forms and shows them on a gallery page?
    Thanks

  11. samavia says:

    TDO mini form is a best plugin

  12. Adam says:

    5 days straight, thank you…. thank you!

  13. Hobrecht says:

    Hi there.
    Is this hack still working with the version 0.13.9?
    I do have some problems to get it working and wonder if there have been changes …

    • Tschai says:

      I wouldn’t know that…and I’m not using this plugin/hack anymore.
      I’m afraid you’re on your own with this one.

  14. david lawton says:

    I’m looking for help trying to make a video upload form so that the video becomes embedded in the post with wordtube plugin and/or jw player(like you said above this requires some hacking), and the user can submit a thumbnail using p75 simple thumbnails. Essentially I need help getting some functionality that I have on the back-end for creating posts onto a front-end form. Any tips on how to do this? I’m happy to pay for help.

    I also have another problem with php which requires a custom add_filter to add a meta tag to the which I will pay for help on, it’s beyond my expertise right now.

    Cheers!

  15. Online Blend says:

    Any idea how to make the file upload a required field? Ideally the ‘Attach’ button would not be required, the form would just check that a file has been selected, and then upload upon form submission.

    Cheers!

  16. Tschai says:

    Glad to hear it’s working and thanks for letting know…

  17. Tschai says:

    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…

  18. Derek says:

    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.

  19. Tschai says:

    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…