TDO Mini Forms: upload path/URL mini hack

May 22nd 2009
15 Comments
respond
trackback

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 usefull.

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!

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks

Related posts:

  1. Vista update crashes localhost
  2. The Unstandard theme: widgetized and gravatar-ized

This post is tagged , , ,

15 Comments

  1. 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…

    [Reply]

  2. Tim

    Suggestion in this case

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

    [Reply]

  3. Tim

    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!

    [Reply]

    admin Reply:

    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…
    ;)

    [Reply]

    admin Reply:

    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…

    [Reply]

    Tim Reply:

    No problem!

  4. 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…

    [Reply]

  5. Derek

    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.

    [Reply]

  6. 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…

    [Reply]

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

    [Reply]

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

    [Reply]

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

    [Reply]

  10. 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.

    [Reply]

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

    [Reply]

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

    [Reply]

Incoming Links

Leave a Reply (most recent reply shown at top)