Review system with new comment form

This is sort of a part 2 of the existing tutorial on how to set up review system using comment form. Previous tutorial was made for normal comment form, but this one will show same thing for comment form that is created new comment_form function added in WordPress 3.0.

Original tutorial can be found here: Using comment form to set up review system. I suggest you read this post first before getting into this one. Limitations are explained in that old tutorial already.

All my xScape themes support this by default, and all this is built into the framework. No custom work is needed if you decide to purchase any (or all) xScape themes, and all this will work out of the box, just needs to be activated using a option on the theme settings panel.

New comment form model is setup through the use of comment_form() function. This function has bunch of arguments to set it up, and this makes very hard to use that approach and add rating code there. But, there is a simple way to achieve this by using the actions to hook up into the comment form. This will explain only the form integration part, adding rating values into comments remains the same.

So, you need to add this code into the functions.php of the theme or some other place where it will be loaded from. First example here is to add standard single rating into the comment form.

[php]add_action("comment_form", "gdsr_comment_form_integration");
function gdsr_comment_form_integration() {
echo ‘<p>’;
wp_gdsr_comment_integrate_standard_rating();
echo ‘</p>’;
}[/php]

And, second example is to do it for the multi set, and the number 4 used in that example is the ID of the multi set, and you need to replace it with the ID of your multi set.

[php]add_action("comment_form", "gdsr_comment_form_integration");
function gdsr_comment_form_integration() {
echo ‘<p>’;
wp_gdsr_comment_integrate_multi_rating(4);
echo ‘</p>’;
}[/php]

That is all you need to do to make this work for any theme that uses comment_form() function. Change the hook function above with additional markup if you need.

Comments

Leave a Reply