[wp-hackers] adding custom fields to a comment form

Gregory Lancaster greglancaster71 at gmail.com
Mon Oct 7 19:01:11 UTC 2013


I got it :)

I followed the smashing guide, and no fields showed up.  So I tried just
copy pasting their example code and that didnt work either.   Is there
something wrong with this code I used here:

function add_comment_fields($fields) {

    $fields['age'] = '<p class="comment-form-age"><label for="age">' . __(
'Age' ) . '</label>' .
        '<input id="age" name="age" type="text" size="30" /></p>';
    return $fields;

}
add_filter('comment_form_default_fields','add_comment_fields');

function add_comment_meta_values($comment_id) {

    if(isset($_POST['age'])) {
        $age = wp_filter_nohtml_kses($_POST['age']);
        add_comment_meta($comment_id, 'age', $age, false);
    }

}
add_action ('comment_post', 'add_comment_meta_values', 1);


On Mon, Oct 7, 2013 at 11:57 AM, J.D. Grimes <jdg at codesymphony.co> wrote:

> I tried to send a reply to that earlier, but I don't think it went through
> - I just resent it now, let me know if you get it.
>
> On Oct 7, 2013, at 2:54 PM, Gregory Lancaster <greglancaster71 at gmail.com>
> wrote:
>
> > I was going to (i am tryign to code the plugin I emailed you about myself
> > today, I have all day :)  )  but the is_post_type was depreciated.  Not
> > sure what to use now.
> >
> >
> > On Mon, Oct 7, 2013 at 11:50 AM, Chris McCoy <chris at lod.com> wrote:
> >
> >> I would check for the post type, if its the one you wish to add to do
> the
> >> process like in the tutorial, so it only shows on the comment form for
> the
> >> post type.
> >>
> >>
> >>
> >> On 10/7/2013, 2:45 PM, "BenderisGreat" <greglancaster71 at gmail.com>
> wrote:
> >>
> >>> I did see that, but I need to add the custom comment fields only to the
> >>> custom post type
> >>>
> >>>
> >>>
> >>> --
> >>> View this message in context:
> >>>
> >>
> http://wordpress-hackers.1065353.n5.nabble.com/adding-custom-fields-to-a-c
> >>> omment-form-tp42446p42453.html
> >>> Sent from the Wordpress Hackers mailing list archive at Nabble.com.
> >>> _______________________________________________
> >>> wp-hackers mailing list
> >>> wp-hackers at lists.automattic.com
> >>> http://lists.automattic.com/mailman/listinfo/wp-hackers
> >>
> >>
> >> _______________________________________________
> >> wp-hackers mailing list
> >> wp-hackers at lists.automattic.com
> >> http://lists.automattic.com/mailman/listinfo/wp-hackers
> >>
> > _______________________________________________
> > wp-hackers mailing list
> > wp-hackers at lists.automattic.com
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list