Simple shortcode to check if a user has commented on a certain post

You made 2 small errors. First of all: Shortcode-Functions receive a maximum of 2 parameters: $attributes and $content. $attributes is an array of all the attributes within the shortcode, like [shortcode post_id=123] the attribute post_id will end up in the $attributes array as $attributes[‘post_id’]. $content has the content between the opening and the closing shortcode … Read more

How to remove email id & website box in wordpress comment

You can do by adding few lines of code in functions.php or using Disable Comment plugin. But adding few lines of code would be great. Steps: Go to Editor > Open functions.php file. Scroll down to the end of file and add lines of code given below function comments_custom_settings($fields) { unset($fields[‘url’]); unset($fields[’email’]); return $fields; } … Read more

comment awaiting moderation

No plug-in needed for this. Just open your theme files using the WordPress theme editor or via FTP. Look for the code that is being used to display the notice. It should be in the index.php file, maybe in a content.php file if your theme uses that, and in some cases it’s in your functions.php … Read more

User’s Comments Number: Storing it in a meta field for different uses

I am using this within a plugin, but it can be used within your theme’s function file. // Create field to track users’ comments numbers function display_educadme_user_comments_number($user_id) { if( is_user_logged_in() ) { global $wpdb; $user_comments_number = $wpdb->get_var(‘SELECT COUNT(comment_ID) FROM ‘ . $wpdb->comments. ‘ WHERE comment_author_email = “‘ . get_comment_author_email() . ‘”‘); ?> <h3><?php _e(‘Participation in … Read more

Query comments with non-empty ‘author_url’ value on Admin Comments Screen

We can set the author_url argument of WP_Comment_Query as null (empty string will not work) to search for comments that don’t have an author url. Currently (ver 4.8.1) the has_author_url isn’t supported. Using a sub-query to exclude those comments, with no author_url, using comment__not_in, should work, but wouldn’t probably scale well. Setting fields as ids … Read more