How to use custom taxonomies in TDO Mini Forms

TDO Mini Forms is one of the best plugins for WordPress to allow visitors or users to publish posts and upload files without having to access the admin area. You can select categories for the post, add tags, title, content, etc. However, even after WordPress introduced UIs for custom taxonomies in version 2.8, TDO Mini Forms (or tdomf for short) won’t allow you to select custom taxonomies. In this post you will find how to modify the categories widget for TDOMF to enable custom taxonomies.

First of all, I should warn you to test it throughly first in a local WordPress installation and only then upload it on your live site. I’ve try my best to test it extensively but I cannot guarantee that it will work 100% ok. However, both categories and custom taxonomies (both hierarchical and those that are not) are being correctly saved. If TDOMF supports custom taxonomies later, it will just work, as this mod doesn’t add any strange stuff other than canonical WordPress functions to support the custom taxonomies.

  1. Ok, so the first step is to download TDOMF. Install it and activate it on the plugins area.
  2. Now go to the plugin’s folder. Open the widgets folder and locate the file tdomf-categories-widget.php.  The full path should be yoursite/wp-content/plugins/tdo-mini-forms/widgets/tdomf-categories-widget.phpIf you want to keep it as a backup, cut this file and paste it outside of the widgets folder.
  3. Download the modified widget that supports custom taxonomies
  4. Decompress it in the widgets folder. That’s it, you can go back to your admin and create a form. If you’re new to TDOMF, you might find the installation and usage instructions useful.

After you set up the options for your form, enter Form Creator.

Select the number of widgets that you want. At least two, one for the regular WordPress categories and one for your custom taxonomy. Click save. Now drag the two widgets from the Available Widgets block to the Your Form block.

We are now going to tell TDOMF to use our custom taxonomy. Access the Categories # widget properties and set the Taxonomy Slug to your taxonomy name. By default, the widget will contain category as the taxonomy slug, that is, the standard WordPress Category taxonomy.

For instance, if you created your custom taxonomy with:

[php]

function register_taxonomy() {

register_taxonomy(
‘color’,
array( ‘post’ ),
array(
‘public’ => true,
‘labels’ => array(
‘name’ => __( ‘Colors’ ),
‘singular_name’ => __( ‘Color’ )
),
‘hierarchical’ => true,
)
);
}

[/php]

The taxonomy slug will be color. Set the other options like with the usual TDOMF Categories Widget. After you set the values you can preview your form on Your Submissions. For instance, I’ve set the categories to be displayed as checkboxes.

So that’s pretty much it, now you have custom taxonomies for TDO Mini Forms. Keep in mind that this is a temporary fix, it won’t be long until TDO Mini Forms will support custom taxonomies but again, with this modified widget the categories and custom taxonomies are saved in the regular WordPress way so they will still be there when TDOMF is updated.

40 thoughts on “How to use custom taxonomies in TDO Mini Forms”

    1. Humm I don’t think I would go that far. It’s better if features so huge like those are implemented by the core developer, in this case, Mark Cunningham.
      How would you like to use post types in TDO? maybe to submit the form as different post types? or is it something else?

    1. Those are very sad news. He should go on and release this plugin under a paid model business. I would buy it without thinking it twice.

  1. […] How to use custom taxonomies in TDO Mini Forms (from ilovecolors). TDO Mini Forms is one of the best plugins for WordPress to allow visitors or users to publish posts and upload files without having to access the admin area. You can select categories for the post, add tags, title, content, etc. However, even after WordPress introduced UIs for custom taxonomies in version 2.8, TDO Mini Forms (or tdomf for short) won’t allow you to select custom taxonomies. In this post you will find how to modify the categories widget for TDOMF to enable custom taxonomies. // […]

  2. Thanks. Pretty cool and useful. For me thought there is one problem. This fix only works for when you want to restrict users to existing taxonomies but I wanted users to be able to create their own new taxonomies. I have taxonomies such as “designer” and “store” and of course there are new designers and stores all the time and the lists would get very long too.
    Is there any way that you could add a simple text input option?

    BTW, This is a beautiful and well finished website. Nice work.

    1. Al, your suggestion was an interesting one so I took a shot by adding an input field to allow entering new additional terms. Download the new widget. Since I wanted to allow users to choose if they want to display it or not, I set it to work only when checkbox listing is selected on the proper widget in the Form Creator view. It will work only for custom taxonomies (it is easy to make it work for regular categories but you should keep these for internal use in your site). It works to create the terms (single or multiple) and checks if the terms already exist avoiding duplicates. Works for the preview on Your Submissions as well. The names for the new terms (not the slug) will be capitalized, in case user forget to enter capital letters.
      So in short, the steps to use this widgets after you have replaced the widget in the TDO Mini Forms directory are:

      1. go to Form Creator
      2. add the new categories/custom taxonomies widget
      3. in the “Display categories as:” block, select the “Checkboxes” radio button.
      4. save and go to Your Submissions

      Now the fieldset for the custom taxonomy will display an additional field labeled “Enter additional terms”. I will be updating it later by adding a checkbox for the user to choose if they want to display it or not in any of the categories display format: drop down, checkbox or list.

  3. Thanks. I tried it out but in its current format it won’t work on my site. In one of my taxonomies I have hundreds of tags so listing them on the page would be crazy. Thanks for putting this together though. I really appreciate the effort and time it takes to code these things.

  4. Correct, I will let you know when it’s available for all categories display formats later this week. The drop down format should suit you better.

  5. Hi, Just installed your modification along with latest TDO Mini forms on WP 3.0.3.

    I’ve got 4 custom taxonomies that appear correctly on my submit post page as check boxes. However when its posted into the system it seems to add the ticked taxonomies using their ids rather than their textual label (hope that makes sense).

    Is there a fix for this or should I hack the form and change the values from ids to taxonomy names.

    cheers
    KB

    p.s cracking job on this mod – just what I needed

    1. Hi KB, yes you’re right. Since this mod is an unofficial one (from the fact that it’s a mod, it’s intended for developers, not the Average Joe), you must hack the form and enter the labels by hand.
      For instance, this is a reduction of the form hacking used in the submit form on graphicsnippets.com/submit/

      [php]
      <!– categories-2 start –>
      <fieldset>
      <?php $defcat = 1; if(isset($post_args[‘categories-2’])) { $defcat = $post_args[‘categories-2′]; } ?>
      <label>Color Tags</label>
      <ul class=’tdomf_category_checklist’ >
      <li>
      <input value="5" type="checkbox" name="categories-2[]"<?php if( isset( $post_args[‘categories-2’] ) && in_array( 5, $post_args[‘categories-2’] ) ) { ?> checked="checked" <?php } ?>/> Gray
      </li>
      </ul>
      </fieldset>
      <!– categories-2 end –>
      [/php]
      Glad you found it useful 🙂

  6. Hi Elio,

    Yep I hacked the form and changed the select values in “Core Form” and did a test post and now my new post shows up with the correct taxonomy name rather than its id.

    Sweet!

  7. Hi
    Not sure if this is the same thing, and I am not as clever as a developer, but I want to try to work out how to use a custom field as a tag.

    eg: I have a custom field called postcode, and I want to have that postcode ALSO used as a tag.

    I assume this is probably easy, but it isn’t for me 🙁

    Any help, or guidance in the right direction, would be appreciated.

    Thanks

  8. Hi Elio,

    First, kudos for making this version of TDO Mini Forms available. It’s exactly what I’ve been looking for.

    I’m using your version of the plugin with custom post type and custom taxonomy support. I was able to get the form itself to look the way I want with my custom post and 4 custom taxonomies. But I’m not able to get the form output to display the custom taxonomies. (All the data is stored correctly in the database, it’s just not shown on my new post created using the form.) Am I supposed to add additional code to the form so that it’ll display the custom taxonomies in the form output? Do I use the form hacker or one of the php files in the TDO Mini Forms widget?

    Thanks. I’m a newbie so any help is highly appreciated.

  9. I think I figured it out – nevermind. In case anyone else is a newbie like me, you’re supposed to add the additional code in your theme’s template files to display the custom taxonomy.

  10. Of course, ES, you need to add the proper code to display your custom taxonomies since they are not as well spread and “standard” like post tags or categories. You might want to check the get_the_term_list function to display your custom taxonomies.

  11. Great hack! I spent hours trying to figure out what was changed but it makes perfect sense.

    I’m trying what KB went thru but with a dropdown list. When I look at my post, my custom taxonomy has the ID, not the name.

    Hacked Form example for a City Taxonomy:
    Select a city:

    <option value="272"
    >All Cities
    <option value="271"
    >Atlanta
    <option value="258"
    >Austin
    <option value="268"
    >Boston
    <option value="264"
    >Chicago

    Also, I’d like to know how to have the category and the taxonomy shown in the admin notification email instead of “Uncategorized”. Any ideas?

    Thank you.

    1. The widget should work out of the box even without using the form hacker, but anyway, here’s an excerpt of my own hacked form:
      The widget should work out of the box even without using the form hacker, but anyway, here’s an excerpt of my own hacked form:

      [php]
      <select name=’categories-2′ class=’tdomf_categories-2′ size=’1′ >
      <option value="25"<?php if( (is_array($defcat) && in_array(25, $defcat))
      || ( 25 == $defcat ) ) { echo ‘ selected="selected" ‘; } ?> >
      Orange
      </option>
      </select>
      [/php]

  12. Thanks for useful addon i was looking for this for quite a time.
    I’ve been wondering if you could make autocomplete suggest for tag. I’m ready to donate some coins ;). I’m asking you because original author seems to don’t give a shit anymore abut plugin..

  13. this seems to don’t work if u upgrade to 3.1.. when u select tag or category u wont tag name i.e. category but numbers, id of that category – tag…

  14. Hi, it’s a wonderful plugin, but with wordpress 3.1, the category-function does not seem to work. Even if I use the category-selection (with $defcat), the post will allways be stored in the default category, even if I have selected another one. Any help or idea how to fix it?

    Thank you!
    Sebastian

  15. Sorry, my mistake, it works after resetting the form, I probably hacked something wrong….

  16. Hey! Really awesome edit, I am using on http://www.uleadnetwork.org/post and pleased with the results except for one issue, the values are displaying as numbers instead of the value name, I really need this fixed and am looking at the widget code but am not clear on what needs to change for this to display correctly. I am unable to hack the form to correct this because of another issue I am having which is trying to get the tags to display as checkboxes. I have found another hacked widget to make the tags display as checkboxes but when I hack the form it reverts back to the text box for tags… ANY HELP?? THANKS!!

  17. Just a minor change to save having to hack the output each time. Rather than have Title of Taxonomy then Select a Category. It would be ideal to have Select a [Title of Taxonomy] so for taxonomy Cost it would say Select a Cost: of for a Category it would say Select a Category. I know its lines 176-186 but having trouble with the syntax (not enough coffee). Great widget though even manually hacking the layout, it definitely has a future. Cheers

  18. Hi,
    it is possible to use the addon as an Title-präfix? It looks like “[new]PostTitel”? verry happy to answer me, my english are very bad 🙁

  19. How do you have this carry over to the actual post itself? After I submit a post, the new information is not displayed in the post, I know there is some code I need to include into my theme in order for it to work right… what code and where? Thanks!

  20. Hey Elio, this is great mod, but on latest tdo mini forms version Im getting this error:

    Fatal error: Cannot use object of type WP_Error as array in C:xampphtdocscheckerwp-contentpluginstdo-mini-formswidgetstdomf-categories-widget.php on line 156

    Any idea how to fix this?

Leave a Reply