ThemeShaper Forums » Thematic

[closed]

Add custom fields on comment template

(6 posts)
  • Started 2 years ago by 1visible
  • Latest reply from helgatheviking
  • This topic is not resolved
  1. 1visible
    Member

    Hi to all,
    I'm trying to add 2 custom fields under default name/mail/web fields.
    But cannot get it to work, and it doesn't seems to be documented for Thematic.
    Most tricks are online but nothing is working for Thematic (or I'm not able to get them working).
    I've also tried some plugins but nothing 100% working.

    My last and more probant grab and mod is, for functions.php:

    function thematic_add_custom_fields($fields) {
        // Add a thematic-style field for the commenter location
        $fields['location'] = '<div id="form-section-location">';
        $fields['location'] .= '<div><label for="location">' . __( 'Location' ) . '</label></div>';
        $fields['location'] .= '<div><input id="location" name="location" type="text" size="30" /></div>';
        $fields['location'] .= '</div>';
        return $fields;
    }
    add_filter( 'thematic_form_default_fields', 'thematic_add_custom_fields' );

    Without any success…

    Alternatively, how to cut out the "website" field?

    Many thanks for help.

    EDIT: of course, data for the new fields must be db stored, and displayed on front end…

    Posted 2 years ago #
  2. Hi,

    I sincerely hope you are modifying the functions.php in a child theme.

    Are you trying to add extra fields to the comment form?

    If so then you'll need to be filtering WP's comment_form_default_fields and you'll need to be aware that Thematic is also filtering that via thematic_comment_form_args() which is found in Thematic's comments-extensions.php

    What you have posted above will not work for several reasons:
    - thematic_form_default_fields does not exist as a filter in Thematic
    - Your use of the "thematic" namespace in defining the function thematic_add_custom_fields()is wrong. You should use a unique namespace for your child theme instead like 'my_child theme_add_custom_fields()`

    Posted 2 years ago #
  3. 1visible
    Member

    HI,
    Yes I'm using a child theme of course.
    Ok, simply adding HTML fields is easy, but having the data recorded and printed is much much harder (for me).

    I'll take the time to undestand step by step what you're telling here…
    Thanks to you.
    I'll be back soon with my experiments.

    (That said, I'm surprised than nobody have speaked about extra comment fields here.)

    Posted 2 years ago #
  4. you say 'of course', but you'd be surprised the number of people we see hacking header-extensions.php! so we have to ask. ;)

    without really getting into it i presume you'd need to look at update_comment_meta() to save the new info.

    there seem to be plenty of resources out there. 2 tuts:
    http://ottopress.com/2010/wordpress-3-0-theme-tip-the-comment-form/
    http://wpengineer.com/2214/adding-input-fields-to-the-comment-form/

    and a plugin that seems to do it for you:
    http://www.solaceten.info/plugins/wp-extra-comment-fields-v2/

    Posted 2 years ago #
  5. 1visible
    Member

    Hi Helgatheviking,
    Thanks for reply. I know this ressources, but never had them to work here.
    Don't know, maybe Thematic have confused my brain.
    Finally, the fact is I have switched my theme to Sandbox.
    Thematic look amazing but I don't have strudy katanas to play with.
    Definitly PHP job is not my game/goal.
    It took me 1 month to get the things I got in 1 week habitually.
    I prefer to have more control has possible from scratch, without having to learn again from roof to cave how a them is working.
    And keep my dumbly habit to copypaste <?php>, witch is working well for now.

    Thanks.

    Posted 2 years ago #
  6. fair enough. there is, admittedly, a steep learning curve. personally, i have found that my learning of hooks and filters for thematic paid huge dividends in learning how to better use both of those features w/ WP source, but i definitely understand the reluctance. i use toolbox myself a lot. sometimes it is faster to add what you need versus strip out all the thematic parts you don't want. depends on the project.

    Posted 2 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.