Support for custom post types in TDO Mini Forms

It’s been little less than a month when the modified widget for TDO Mini Forms to support custom taxonomies was released. It didn’t allowed you to enter new terms for taxonomies and most important, it didn’t featured custom post types support, so here’s the entire plugin updated for TDO Mini Forms to support custom post types, allowing the addition of new terms for custom taxonomies.
First of all, I’ve been in touch with Mark Cunningham and he will be rolling out the changes in this fork very soon (he even tweeted about it). You might want to follow him or search for the #tdomf hashtag. The version number has not been incremented so you will correctly receive the notification for the next official update. This plugin has been tested in WP 3.0 and 3.0.1.

Installing

The process is no different from installing other plugins for WordPress:

  1. Upload it to your /wp-content/plugins/ folder
  2. Unzip it
  3. Go to the Plugins section on the WP admin and activate it

Adding a form to submit to a custom post type

The custom post type support works at form level, so you will define it on the Form Options section under the TDO Mini Forms settings.
There’s now a new radio button to select custom post types and you can enter the custom post type name in field below. As an example, let’s assume we’re creating a new post type named “job”, to allow users to publish job offers and file them under a proper custom post type.

We can’t rule out the possibility of some bugs hidden somewhere, but it worked smoothly in my experience using it. You can see the custom taxonomies at action at this site (currently under construction), the color tags belong to a custom taxonomy. An example of the custom post type support will be provided later. The widget interface was also revamped a little to better integrate it with the rest of WordPress.

All in all, it works, but if you prefer to wait a bit for Mark to roll out the changes, go ahead. In fact, when Mark rolls out the changes, I will be updating to follow the same path of TDOMF development. For the moment though, it’s a nice substitute. Keep in mind that the posts will be stored, the taxonomies will be inserted in the post, all your data will be ok. When the official update arrives, your data will still be there.

One of the readers, Kris, found a glitch regarding custom post types and posted a fix in the comments below and Robert added a follow up adding another modification.

44 thoughts on “Support for custom post types in TDO Mini Forms”

  1. Andrew, awesome! I think that one of the benefits of using a custom post type to submit all these user generated input is that they won’t appear in the regular posts feed. Of course, we could build a feed for a certain category but that would be too limitating for the overall blog and its topics.

  2. Working great, thanks a lot !

    The only bug I’ve seen is with the custom taxonomy, it will insert the ID of the tag instead the Name in wordpress.

  3. Here is my form : http://mesopinions.ca/concours/ajouter-un-concours/

    It’s the last combobox, named type de prix. It shows correctly the taxonomy values with the proper ID, but when I submit and go to the custom post type, I see the ID instead of the name. It’s like it created a new one. It’s not the end of the world, I can correct it manually when someone submit a post (check the ID and readd the correct taxonomy). What configuration info you need ?

  4. This is a great step. I’m having one issue though. Let’s say I make a form and set the custom post type to “Cats”. Then I make a second form and set its custom post type to “Dogs”. If someone submits a form under the “Dogs” custom post type and hits submit, it’s still saved and published under “Cats”! It’s because this edit takes the custom post type set in the first form and saves it across ALL forms, not just the form it was applied to. Any help with this? Thanks!

  5. Just a quick update, I was able to isolate and fix the bug mentioned above:

    tdo-form.php , line 893: replace

    tdomf_get_option_form(TDOMF_OPTION_CPT)

    with

    tdomf_get_option_form(TDOMF_OPTION_CPT,$form_id)

    1. Hey Kris, that’s outstanding, thanks for taking the time to debug and share it. I’ve pointed a notice on the post to this comment. Great work!

  6. Hi, thanks for this update to an already great plugin.

    I am, however, having issues – the ‘select custom post types’ radio button is nowhere to be seen yet the ‘Enter custom post type name’ field is there??

    The plugin works fine for normal post, I did initially manage to add posts to the custom post (review) section and they would display front and back end but then chuck an sql error:

    “You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘ ”, ”, ”, ”)’ at line 1″..

    Any thoughts on what the issue might be..I have tried reinstalling the plugin version provided again. Now all I can do is update normal posts..hmmm.

    Any help much appreciated.
    thanks!

  7. I’m also not seeing the Custom Post Type radio button, although I do see “Enter custom post type name”. I entered my cpt there and created a form but it still submits as regular posts. Any ideas?

  8. Ditto, after installing the radio for custom type doesn’t show up, just the field to enter the name. any idea how to fix this.

    Thanks a mil

  9. Hi Gary, Carlos, James, Paul, sorry for the late reply but I’ve been really busy and didn’t wanted to leave a short and useless reply. Actually, it’s my fault, in the last update to the plugin the radio button was removed since custom post types share (almost) the same procedures with regular posts. So to submit custom post types you can simply leave the option set to “Posts” BUT make sure you do enter the correct handler for your custom post type. After this, you’re all ready to go.
    In addition, I’ve just tested the plugin using WordPress 3.1 Beta 2 + TwentyTen 1.3 Alpha and it’s working smoothly submitting the custom post types correctly.

  10. Thanks a mil Elio, it worked.

    How do I set the “default category” to one of my custom taxonomies? It shows “uncategorized” as the default.

  11. I want I was referring to was the “Default Catergory” setting in the form options, not the category widget. The default category for the form is set to “uncategorized.” I would like to set the option to one my my custom categories/taxonomies. Not the category widget part

    Thanks a lot!

  12. A big thanks to Kris for his fix on secondary forms using the type of the first form. I however had to make an additional change in order to fix this.

    In the same file “tdo-mini-formsincludetdomf-form.php”

    On line 892,
    Change “if(tdomf_get_option_form(TDOMF_OPTION_CPT) != “”) {”

    to
    if(tdomf_get_option_form(TDOMF_OPTION_CPT,$form_id) != “”) {

    Hope it helps someone else.

  13. has anyone figured out how to change the default category?

    I changed the above code to reflect CPT but my submissions are not veiwable as they are still trying to post under the ‘default category’. I’d like to change the ‘default category’ to my CPT.

  14. Hmmmmm… For some reason I can’t quite get this to work. Fresh install of both WP and the plugin.

    I add the custom post type “businesses” to the form options, but it just won’t post to that CPT after a submission. It just goes to the standard Posts.

    Am I missing something super simple?

  15. Hello, is there a way to have more than 10 custom field widgets? Seems the max is set to 10, but my theme uses a heck of a lot of custom fields.

    Many thanks

  16. Hi, I also need to post to a Custom POst Types.
    I uploaded the plug in.
    1 – Choice of categories does not display in the form
    2 – It did not work for me, I wrote the name of my custom post types in the field in form option but still wrote to Articles
    Any advice ?

  17. @Mihir, yes you can upload image or even file using TDOMF.
    1 – Use the form creator
    2 – Select in AVAILABLE WIDGET ‘Upload file’
    3 – Drag it to ‘YOUR FORM’
    4 – Set all parameters (extension, file to upload etc…) clicking on the right top box
    You will have an upload filed on your form where users can submit image.

  18. Hi guys.. I couldnt get the plugin to recognise the custom post type.

    but here is what you can do ..

    Set it in the “Append to Post” widget.

    $postdata = array(
    “ID” => $post_id,
    “post_title” => $post_title,
    “post_type” => “your custom post type name”
    );
    sanitize_post($postdata,”db”);
    wp_update_post($postdata);

    more info on this link

    http://thedeadone.net/forum/?p=418#comment-1542

  19. Has anyone had any luck getting this to work with a custom post type? It just keeps hitting up ‘Posts’ instead of ‘Competitions’ as it should…

    Should the ‘Custom Post Handler’ in tdomf be plural? capitalised? Is there a convention there that i’m mucking up?

  20. Ive been trying to get the excerpt textarea to automatically fill with the value of a customfield textarea value.
    I can get the form to work fine if I change the name=”excerpt-ta” to not have a hypen onkeyup=”excerptta.value=this.value” but that obviously won’t post properly. Anyone know of a work around to be able to use the plugins excerpt-ta.value?

  21. When I try to install TDO mini forms with the Magazine Basic theme at don’t display the form properly if you are creating the form in a page. But it is displayed properly when used in a widget. Is it a bub of TDO Mini form?

  22. Hello,

    I have already heavily custimized the settings of TDOmini forms and then i realized that i would like the post_type feature you are offering in your mod. Is there any way of upgrading to this plugin and retaining my old settings? or do i just have to wipe the old plugin out and install your version?

    1. I really don’t think so. The author of TDO Mini Forms is seldom updating the plugin due to time restrictions but last time we talk he mentioned he would be implementing this in the plugin.

  23. very understandable, it already an amazing plugin. especially for giving it away for free

    Tired out the custom post type seemed pretty good but i couldn’t get the custom fields to save. I’ll keep playing with it, as it was late when I was testing 🙂

    thanks so much for sharing this.

  24. Unfortunately the submitted posts use the blogs permalink-structure which is quite different than the custom rewrite slug for my custom post type. So when a post is submitted I get a wrong URL. Any suggestions on how I can solve that problem? I can’t edit the permalink structure.

  25. Hey! awesome edit of an awesome plugin! I just wanted to pipe in and say that your edit doesn’t properly handle mutiple custom post types on different TDOMF forms.

    In tdomf-form.php file on or around line 891 you need to change the code to:
    else{
    if(tdomf_get_option_form(TDOMF_OPTION_CPT,$form_id) != “”) {
    $post[‘post_type’] = tdomf_get_option_form(TDOMF_OPTION_CPT,$form_id);
    }
    }

    to account for the possibility of multiple custom post types.

  26. A person essentially help to make significantly posts I’d state. This is the very first time I frequented your web page and so far? I amazed with the research you made to create this actual submit extraordinary. Magnificent job!

  27. Hey ! Great solution for the custom post types issue.

    TDO-Mini-Forms is a great work and highly functional plugin which was released when no other ways were existed at the time. Unfortunately some angry users made the author(Plugin author) suffer and he drew back from maintaining the plugin. And now the plugin was disappeared from the official WordPress repository.

    I wish the experts like you could modify the code according to the latest versions and release it as “Reloaded”. Many of the TDo miniforms fans are waiting for such plugin

    Thanks !

Leave a Reply