AI Assistant
Notifications
Clear all

Function in comments.php doesn't work with Wpdiscuz

2 Posts
2 Users
0 Reactions
5,611 Views
(@gharsalli)
Member Customer
Joined: 8 years ago
Posts: 1
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
  [#3475]

In comments.php file, I have this snippet to limit the number of comments a user can submit per day.

<?php 
global $wpdb,$current_user;
$limit = 1; //this is limit per day per user
$comment_count = $wpdb->get_var( $wpdb->prepare("
SELECT count(*)
FROM wp_comments
WHERE comment_author = '%s'
AND comment_date >= DATE_SUB(NOW(),INTERVAL 1 DAY);"
,$current_user->user_login) );

if($comment_count < $limit) {
echo 'You submited '.$comment_count.' comment(s) from '.$limit.' available ';
comment_form( hestia_comments_template() );
}
else {
echo 'You have reached your comments daily limit : '.$limit;
}
?>

This code work perfectly with WP core comment system, but when switch to wpdiscuz, it doesn't work at all.
Any suggestion or change to let wpdiscuz supports this code.
Thanks



   
Quote
Topic Tags
Astghik
(@astgh)
Illustrious Member Admin
Joined: 8 years ago
Posts: 6645
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

Hi @gharsalli,

I apologize for the delay.

Yes, the code will not live with wpDiscuz. The code in this support topic should help you.

https://wordpress.org/support/topic/one-comment-per-user-per-post-2/



   
ReplyQuote
Share:
Scroll to top