Notifications
Clear all

Limited Support

Our team is currently on holiday, so support will be limited during this period. Response times may be slower than usual, and some inquiries may be delayed. We appreciate your patience and understanding, and we’ll resume our usual support by the end of August.

 

[Solved] Guest user author stats lost when registering and using same email

2 Posts
2 Users
1 Reactions
2,009 Views
Posts: 1
Customer
Topic starter
(@thepsir)
Member
Joined: 6 years ago

Hello, i am here to propose a sollution to anyone facing this problem.

Our sites have communities that was guest based, and the author information was showing up based on guest email. 
Now, we allowed register/login functions to our users, and when they register using the same email, the plugin shows only the comments made from the current (new user) user id.
To prevent this from happening, we made the following modifications on the addon code:

1) plugins/wpdiscuz-comment-author-info/includes/wcai-helper.php
Change line 167 from
$allComments = $this->dbManager->getAuthorAllComments($user->ID);
to
$allComments = $this->dbManager->getAuthorAllComments($user->ID,$user->user_email);

2) plugins/wpdiscuz-comment-author-info/includes/wcai-dbmanager.php
Replace the function getAuthorAllComments (line 16 to 25) to this: public function getAuthorAllComments($userId, $email = '') {
$result = '';
if (trim($email)) {
$sql = $this->db->prepare("SELECT `comment_ID`, `comment_approved` FROM {$this->db->comments} WHERE `comment_author_email` = %s", $email);
} else if (intval($userId)) {
$sql = $this->db->prepare("SELECT `comment_ID`, `comment_approved` FROM {$this->db->comments} WHERE `user_id` = %d", $userId);
}
$result = $this->db->get_results($sql);
return $result;
}

Hope that this help everyone that needs it. 

1 Reply
Astghik
Posts: 6444
Admin
(@astgh)
Illustrious Member
Joined: 8 years ago

Thank you @thepsir. I really appreciate you taking a time and share this information.

Share:
Scroll to top