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'd like to create a custom comment type based by thread level. The initial comment on a given post (top tier comment) would require the commenter to enter a title (I assume this would be a new database field since comments don't typically have titles) and then enter the comment in the typical comment body field.

However, f someone were to reply directly to this comment (2nd tier comment) then they would be presented with the standard comment box that does not require a title.

Would something like this be possible in WP via creating a custom plugin, etc?

Much appreciated.

Eddie

share|improve this question
add comment

1 Answer

I don't know why somebody downvoted this question. This is a GREAT question.

Yeah, that's totally possible. What you would want to do is use comment_meta to store the titles. You could add the new field into the form using the 'comment_form_top' action. It runs before name, email, and url, and still runs if the user is logged in, so you'd get the field for every user. Just echo the html directly.

Then you'd want to hook into 'pre_comment_on_post' to check if there's a title. Use wp_die() to exit execution if there's nothing there.

You should hook into the 'comment_post' action to save the title. That hook passes two arguments: the comment_id and the comment's approval status. The only one you should need is the comment ID. Sanitize the input with esc_attr() and add the comment_meta.

The last thing you might consider is adding some javascript that would automatically set the title and hide the field for comment replies. The comment reply links all have a class of 'comment-reply-link', so it wouldn't be too difficult to hook in with jQuery.

Hope that helps you get on the right track!

share|improve this answer
add comment

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.