well wisher
asked 6 years ago

Hey guys i can see users email ids used as username in recent comments widget of my site instead of anonymous can you confirm this issue and get it resolved asap thanks

5 Answers
well wisher
answered 6 years ago

anyone?

BigHug
answered 6 years ago

Hey Well wisher, 
Please add this custom code into your theme functions.php


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

This is a quickfick to make a mask for your anonymous comment
Regards

well wisher
replied 6 years ago

thanks for the support and code @Bighug 🙂

well wisher
replied 6 years ago

one thing more have you guys knowingly switched of the voting and follow feature more mobile devices of smaller screen sizes because i am unable to them lately when visiting my site by mobile

well wisher
answered 6 years ago

it turned all comments anonymous !!!

BigHug
replied 6 years ago

That’s weird. As you can see in the code, i checked author id before convert their author name to anonymous so it should be that all new comments posted by anonymous users only.

well wisher
replied 6 years ago

yaa i know its weird but still its happening may be because you took the global $current_comment variable but dint used it as i see its commented over there using //
i think the code should be like something i have mentioned in answer below

well wisher
answered 6 years ago

Any lead on this ?

well wisher
answered 6 years ago

ok this is what the scenario is if user is logged in then the code works else not i think was testing it late at night

well wisher
answered 6 years ago

Guys can you confirm this issue?

BigHug
replied 6 years ago

Hi Well Wisher,
Sorry for my late reply, can you provide me an admin account for further checking, i want to improve the code that i sent to you before

well wisher
replied 6 years ago

Hi @BigHug at the moment the only thing i can provide is the link to my site where you can see the problem here you go http://brainlubricator.com/identify-fake-fraud-company/ check out the comments section there

well wisher
replied 6 years ago

as i already informed you above that the code works when logged in as admin but fails when the comment is made using the form without logging may be because you are checking the user_id eg 1 for admin 2 for author etc i and <=0 makes anonymous but using the comment_id may resolve this issue

BigHug
answered 6 years ago

I saw the problem. Here are my improvement for this code. It will only turn the comment author to anonymous for Question Answer Post type:

function dwqa_anonymous_comment_author_link( $comment ) {
// global $current_comment;
$comment_post_parent_type = get_post_type( $comment->comment_post_ID );
if( $comment->user_id <= 0 && ( $comment_post_parent_type == 'dwqa-question' || $comment_post_parent_type == 'dwqa-answer' ) ) {
$comment->comment_author = __('Anonymous','dwqa');
}
return $comment ;
}
add_filter( 'get_comment', 'dwqa_anonymous_comment_author_link' );
well wisher
replied 6 years ago

wait for a moment let me check it ,will inform you in a minute or two

well wisher
replied 6 years ago

nope nothing changed its still saying anonymous

well wisher
answered 6 years ago

@bighus i want you to have a look here i was thinking to implement these to achieve the purpose http://codex.wordpress.org/Function_Reference/comment_author

Displays the comment author name; that is, the one supplied by the commenter. If no name is provided (and “User must fill out name and email” is not enabled under Discussion Options), WordPress will assign “Anonymous” as comment author.
Use get_comment_author() to retrieve the value.

http://codex.wordpress.org/Function_Reference/comment_author_email
http://codex.wordpress.org/Function_Reference/comment_author_link
http://codex.wordpress.org/Function_Reference/get_comment_ID
http://codex.wordpress.org/Function_Reference/comment_ID
This is how wordpress do its anonymous comment thing i thought the answer to this problem may be found here i tried doing the stuff but achieved no success
Hope this helps

well wisher
answered 6 years ago

Hi @bighug the issue is still there even after the latest update and there are more problems like answer page is breaking scripts and answer form is not working

BigHug
answered 6 years ago

Hi Well !
Apologies for the delay in replying to you.
The latest version of the DW Q&A plugin has already been released with bug fixes. Could you kindly upgrade it and let us know if you face with any problems.

well wisher
replied 6 years ago

Yes, i have updated to the latest version few days back and it has resolved the issue @Bighug thanks for the great work 🙂

well wisher
replied 6 years ago

i am just curious bout what made the difference(only if you have time to give an small idea) ?

Powered by DW Question & Answer Pro