Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I need to create a user comment form with three text areas and then display them in comments. I don't know where to start - cannot find any plugin but would like to code it anyway. Any pointers much appreciated.

share|improve this question

2 Answers 2

To add new fields, simply append them to the default fields with a plugin.

<?php
defined( 'ABSPATH' ) AND exit;
/* Plugin Name: (#85059) Append form fields to comment form */

add_filter( 'comment_form_default_fields', 'wpse85059_comment_form_extd', 100 );
function wpse85059_comment_form_extd( $fields )
{
    // Append new fields …
    if ( 'comment_form_default_fields' === current_filter() )
    {
        foreach ( array( 'ctax_1', 'ctax_2', 'ctax_3' ) as $ctax )
            $fields[] = "<input value='{$ctax}' name='{$ctax}' />";
        return $fields;
    }
}

Then there's also the possibility to use comment meta data. More about it can be read in the Codex.

To attach the meta data, you can hook into an action:

add_filter( 'comment_id_fields', 'wpse85059_comment_meta_fields', 10, 3 );
function wpse85059_comment_meta_fields( $result, $id, $replytoid )
{
    add_action ( 'comment_post', 'wpse85059_comment_meta', 1 );

    foreach ( array( 'ctax_1', 'ctax_2', 'ctax_3' ) as $ctax )
        $result .= "<input value='{$ctax}' name='{$ctax}' />";

    return $result;
}
function wpse85059_comment_meta( $comment_id )
{
    // Only run once
    remove_filter( current_filter(), __FUNCTION__ );

    foreach ( array( 'ctax_1', 'ctax_2', 'ctax_3' ) as $ctax )
        add_comment_meta(
             $comment_id
            ,$ctax
            ,$_POST[ $ctax ]
            ,true
        );
}

Note: This is not tested, but should give you a starting point.

share|improve this answer
    
Thanks, will try and work it out and get back to you. –  user1684099 Feb 8 '13 at 12:46
    
@user26166 Feel free to edit my answer with a full & working solution. I'll approve it. –  kaiser Feb 8 '13 at 13:24

3 textares for what purpose? or you meant 2 input´s and 1 texarea plus 1 input button? i would start reading at http://codex.wordpress.org/Function_Reference/comment_form

share|improve this answer
    
3 textareas to catagorize comments for a review system, thanks. –  user1684099 Feb 8 '13 at 11:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.