Limit comments per user per post

I think that hook pre_comment_approved should be perfect in this case. Something like this should do the job: function my_pre_comment_approved($approved, $commentdata) { // you can return 0, 1 or ‘spam’ if ( $commentdata[‘user_ID’] ) { $args = array( ‘user_id’ => $commentdata[‘user_ID’], ‘post_id’ => $commentdata[‘comment_post_ID’] ); $usercomment = get_comments( $args ); if ( 1 <= count( … Read more

Automatically increase comment karma on comment save

The comment_karma field in the wp_comments table is something that has been in present in WordPress for a long time, but never utilized by the WordPress core itself. You can update it the same way any other comment field is updated, using update_comment(): $comment_data = array(); $comment_data[‘comment_ID’] = 1; $comment_data[‘comment_karma’] = 123; wp_update_comment( $comment_data );

Add filter to comments loop?

It is hard to say what you need to hook into without knowing all the details but I think you may be able to use comment_text— more or less the the_content of comments. add_filter( ‘comment_text’, function ($comment) { return $comment.'<div>This is your special division</div>’; } ); If that isn’t quite right, take a look at … Read more

Do I need to deal with WordPress SQL Injection

Higher-level API functions like this in WP typically do the $wpdb->prepare() call to protect against MySQL injections. As for content by default comments do allow HTML, however it isn’t just anything. If you examine default-filters.php there are quite a few sanitizing functions hooked to processing comment data, including wp_kses_post() which limits HTML to white listed … Read more

save_post action hook for comments

You can try the edit_comment hook that’s fired within the wp_update_comment() function, called by the edit_comment() function when you edit a comment in the backend. This hook is fired after the comment is updated in the database. Example: add_action( ‘edit_comment’, function( $comment_ID ) { // … your code here … } ); Notice the following … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)