Comments Feed & Custom Post Statuses

Found the filter: comment_feed_where to filter the WHERE clause, which by default only looks for posts with status = publish. function comment_feed_where_status($where) { return str_replace( “post_status=”publish””, “post_status=”publish” OR post_status=”resolved” OR post_status=”unresolved””, $one); } add_filter(‘comment_feed_where’, __NAMESPACE__ . ‘\\comment_feed_where_status’); I found this by debugging with “SAVEQUERIES” enabled and dumping the queries array on the feed page.

Making a Comment on a page without being on that page?

You have to set the value of $_POST[‘comment_post_ID’] to the post id of the page: <input type=”hidden” name=”comment_post_ID” value=”10″ /> Then set the action of the form element to /wp-comments-post.php, filter ‘comment_post_redirect’ and send the visitor back to page where the comment/review was written. Here is an example, written as plugin: <?php /* Plugin Name: … Read more

How to disable empty tags in comment_text()

If you look in wp-includes/default-filters.php you’ll see all of the functions each comment is run through before it’s output. I’d guess it’s the last one, wpautop, which adds p tags in place of line breaks: add_filter( ‘comment_text’, ‘wptexturize’ ); add_filter( ‘comment_text’, ‘convert_chars’ ); add_filter( ‘comment_text’, ‘make_clickable’, 9 ); add_filter( ‘comment_text’, ‘force_balance_tags’, 25 ); add_filter( ‘comment_text’, … Read more

Only subscriber role user can comment not other

I suggest adding a snippet to the theme file where the comments form is loaded that checks to make sure there is a logged in user and then, if that user a Subscriber, then show the comments form to them. The examples below use the Twenty Sixteen theme: In comments.php: // First, get the current … Read more

How to make comment text field un-required?

You can circumvent the check for empty comments easily by adding the uploaded image as HTML to the comment text: add_action( ‘pre_comment_on_post’, ‘allow_empty_comment_text’ ); function allow_empty_comment_text( $text=”” ) { if ( ! isset ( $_POST[‘comment’] ) or ” === trim( $_POST[‘comment’] ) ) { $img = ‘/* Process uploaded image here, create an <img> tag. … Read more

Add delete, approve, spam Links to Comments

Per default wp_list_comments() calls the class Walker_Comment. Its method start_el() calls edit_comment_link() and here we find a filter for your question: It is called ‘edit_comment_link’ and it passes two variables, the link text and the comment ID, which we can use. The URLs to mark a comment as spam or to delete it are: wp-admin/comment.php?c=1&action=cdc&dt=spam … Read more