I have a page on a woocommerce site, which I drive users to, to ask for a review...The area for them to leave a review is actually a contact form. I have done it this way, so that they are automatically added to a MailChimp list for email follow up when they fill in the review form. (contact form 7 supports this mailchimp integration).

What I would like to do is automatically/programmatically take that contact form info and fill in an actual review for a product in its comments section, once the user clicks submit.

Is that theoretically possible?

I have limited programming understanding so want to make sure it's possible, so that I can decide whether to hire someone else, other than the baffoon I am currently working with.

1 Answer 1


First add 1-5 * (star) Radio button on comment form.

add_action( 'comment_form_logged_in_after', 'add_review_field_to_comment_form' );
add_action( 'comment_form_after_fields', 'add_review_field_to_comment_form' );
function add_review_field_to_comment_form () {
echo '<p class="comment-form-rating">'.
'<label for="rating">Rating</label>
<span class="commentratingbox">';
    for( $i=1; $i <= 5; $i++ )
    echo '<span class="commentrating"><input type="radio" name="rating" id="rating" value="'. $i .'"/>'. $i .'</span>';

Now save the Rating value to comment meta.

add_action( 'comment_post', 'save_comment_rating_data' );
function save_comment_rating_data( $comment_id ) {
if ( ( isset( $_POST['rating'] ) ) && ( $_POST['rating'] != '') )
$rating = wp_filter_nohtml_kses($_POST['rating']);
add_comment_meta( $comment_id, 'rating', $rating );

Now show the rating if there is any.

add_filter( 'comment_text', 'display_rating_on_comment');
function display_rating_on_comment( $text ){
if( $commentrating = get_comment_meta( get_comment_ID(), 'rating', true ) ) {
    $commentrating = 'Rating : '.$commentrating.' STAR';
    $text = $text . $commentrating;
    return $text;
} else {
    return $text;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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