How to list commenters and days since last commented

It looks like you could add the MAX( comment_date ) last_commented_date to the field list to get the latest date, each user commented. Then use e.g. the human_time_diff() function to get a human readable text for how long ago each user commented. human_time_diff( strtotime( $result->last_commented_date) ) For safety reasons, you should then prepare the SQL … Read more

SQL Command for restoring trashed comments

I would discourage using raw SQL for moving a post to a trash or back, especially since there’s a build in function for it: wp_trash_post( $post_id ); More about the wp_trash_post() function. The opposite is: wp_untrash_post( $post_id ); wp_untrash_post() also untrashes trashed comments. In WP there are functions for many things – for instance you … Read more

Remove the function which adds nofollow to links in comments

Add this to your plugin file/theme’s functions.php: remove_filter( ‘pre_comment_content’, ‘wp_rel_nofollow’, 15 ); You could then add your own filter to pre_comment_content to use wp_rel_nofollow selectively, based on your criteria. URLs that are automatically made clickable from plain-text urls like example.com aren’t filterable in a way that allows removing of the rel=”nofollow” attribute. The only solution … Read more

How to Add text to the start of all comment?

You can use this filter hook to add this apply_filters( ‘pre_comment_content’, string $comment_content ); Here is the code how you can use this function add_custom_comment_content( $comment_content ) { // You can handle it many ways $comment_content .= “Custom Content” } add_filter( ‘pre_comment_content’, ‘add_custom_comment_content’, 10, 1 );

Conditional: IF current user has NOT commented on current post (not including post author)

[EDIT] Here is the modified code: $post_id = get_the_ID(); // ID of the current post. $user_id = get_current_user_id(); // ID of the current user. $post_author_id = get_post_field( ‘post_author’, $post_id ); $is_post_author = ( $user_id && $post_author_id == $user_id ); $can_comment = $is_post_author; /* * If $can_comment is not yet TRUE, then it’s because either: * … Read more

How to amend time format of comments, using child-theme?

You have to return the formatted date string, the following will work: // define the get_comment_time callback function filter_get_comment_time( $date, $d, $gmt, $translate, $comment ) { $d = “g:i:s”; $date = mysql2date($d, $date, $translate); return $date; }; // add the filter add_filter( ‘get_comment_time’, ‘filter_get_comment_time’, 10, 5);