SB Author Comments: Author Commenting plugin for WordPress

April 15th, 2010 by Sean Leave a reply »

To my knowledge it’s not possible to comment on an author in WordPress. “Why would you want to do that?” you ask… Well for example a client of mine is running a classifieds site using the Classipress theme. The site uses classifieds as jobs for people to do and the people posting and signing up to the site are tradesmen. Comments, in this case, can be used as a feedback system and therefore are a valuable addition.

The wp_comments table doesn’t have support or scope to store comments with an associated user (as opposed to post). At this juncture I would have inserted a null (or 0) value into the post_id column and added a row into the wp_commentmeta table with the user ID it refers to. However, I didn’t write the core code for the project so I simply updated a neat little system written by Dan Wellman. Dan’s system is pretty good and uses AJAX and JSON to add comments to a new database table with two fields (author and comment). It was what I would call ‘a good start’ as DB details were required in a number of different files and the database had room for improvement. I have a few more plans for the code but for now have changed a couple of things and bundled it into a WordPress plugin for you.

In my version the database table is created for you, it has several more fields including a primary key (!), timestamps and room for additional information (not currently utilised) to be stored. The WordPress database class is used now so no duplication of the connection details is necessary.

Take a look at the plugin and comments and suggestions for additions are very welcome.

Download
SB Author Comments (1.84 kB)

Usage
Upload and activate the plugin as normal. Then add the following code to your author.php theme template making sure to edit the $author_id variable as appropriate.

<?php
if (function_exists('sb_ac_comment_form')) {
echo sb_ac_comment_form($author_id);
}
?>

Credit
Once again credit goes to Dan Wellman who detailed the integration into his site on his blog

Leave a Reply