How to ‘If Author’ Comments Check

If you use the comment_class function to add classes to each comment, comments by the post’s author can be styled via the bypostauthor class. You can alternately match the comment ID against the post ID: global $post; if( $comment->user_id === $post->post_author ) { // is author comment }

Auto disable comments with custom field

Editing your code to use a custom field is fairly trivial… function close_comments( $posts ) { if ( !is_single() ) { return $posts; } $cmeta = get_post_meta($posts[0]->ID,’your_field_name’,true); if ( $posts[0]->post_date_gmt < $cmeta ) { $posts[0]->comment_status=”closed”; $posts[0]->ping_status=”closed”; } return $posts; } add_filter( ‘the_posts’, ‘close_comments’ ); I am not sure that that approach is the right one … Read more

How can I get a comment ID on Submit?

You can hook comment_post and add your logic with the comment id // Save the data along with comment id add_action( ‘comment_post’, ‘wti_save_comment_data’ ); function wti_save_comment_data( $comment_id ) { // Use the comment id and add your logic }

Comment notification not working

I do not see the $comment_ID variable having any value in your code. So try by changing the following code wp_notify_postauthor($comment_ID, $comment->comment_type); to wp_notify_postauthor($comment->comment_ID, $comment->comment_type); You can also remove $comment->comment_type as per codex

Sort post by last commented

For this you can use WP_Comment_Query. The query will be $comments_query_args = array( ‘post_type’ => ‘post’, ‘number’ => 5, ‘status’ => ‘approve’ ); $comments_query = new WP_Comment_Query(); $recent_comments = $comments_query->query($comments_query_args);

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