A bug in DW Question & Answer makes all comments ‘Anonymous’

While I was busy with semester exams, my colleague figured that all comments are showing to be posted by Anonymous author. How weird? Anonymous name is given to the writer of a comment in which ‘author-name’ field is kept blank. I did not allow to post ‘anonymous’ comments on this blog and everything was okay until I installed the latest update (1.2.9, possibly) of Design Wall’s Question Answer (DWQA) plugin. This Q&A tool has proven to be a tonic to the interactivity of my website since I installed it in March 2014. It is lightweight, packed with features (plus this bug ) — and here , I used it to engage with users who were willing to ask topic specific queries to me.

 

What happened?

I didn’t change anything. As usual, I installed the updates listed as version 1.2.9 and then 1.2.10, though. This is where bug took place into their code. All comment author names, except mine, changed from their regular ones to Anonymous. This happened to both on the front (website) and back-ends (dashboard).  I tried to change them back to custom  ones, they did not change. You can see how they changed:

Screenshot_21

Earlier

Screenshot_20

Later

Any Solutions?

Not yet. Yes. First of all I thought, it was a database error — that’s why I made a restore to an earlier date. After it did not seem to work, I used WordPress support forum to request a help. Support forum didn’t help either. While all techniques were failing, I decided to investigate the plugins activated. As Akismet handles my comments, it was my main suspect. But deactivating Akismet didn’t help.  I deactivated other remaining plugins at once and viola, success!. All comment author names started showing perfectly. I cautiously activated all other plugins except ‘DWQA’ , and all my comments/comment authors were safe and sound.

As I have deactivated DWQA plugin, readers will no longer be able to access the Question Hub. I am expecting a quick bug fix from designwall team and if that don’t come soon, I will be exporting Question Hub to BuddyPress.

While exploring plugins files of DWQA I figured, there was a small faulty code in dw-question-answer/inc/actions.php file on lines 1736 to 1740:

function dwqa_comment_author_link_anonymous( $comment ) {
// global $current_comment;
if( $comment->user_id <= 0 ) {
$comment->comment_author = __('Anonymous','dwqa');
}
return $comment ;
}

Changing that into following did the trick for me:



function dwqa_comment_author_link_anonymous( $comment ) {
// global $current_comment;
if( $comment->user_id <= 0 && ( get_post_type( $comment->comment_post_ID ) == 'dwqa-question' || get_post_type( $comment->comment_post_ID ) == 'dwqa-answer') ) {
$comment->comment_author = __('Anonymous','dwqa');
}
return $comment ;
}