Can I have Comments open to specific users only?

You can check for a user role. This should work when you put the code into the template above the call to comments.php: if ( current_user_can( ‘actor’ ) ) // or use ‘publish_posts’ add_filter( ‘comments_open’, ‘__return_true’ );

How to limit comment indentations to one level?

This can be done, there is even a possibility to control this via the backend, just go to: → Settings → Discussion And there under: → Other comment settings You have the point: → Enable threaded (nested) comments | X | levels deep

Remove the deleted user comment

+1 @toscho ‘s comment. This will break nested comment / conversation in comment. You should disable nested comments in the Settings. Try this code. Note that this is not tested add_action( ‘delete_user’, ‘my_delete_user’); function my_delete_user($user_id) { $user = get_user_by(‘id’, $user_id); // delete comment with that user email $comments = get_comments(‘author_email=”.$user->user_email); foreach($comments as $comment) : wp_delete_comment($comment->$comment_id, … Read more

Get all child comments ids from parent comment id

I found this post because I was looking for a similar solution. As suggested by Captain47, get_comments with parent args, won’t work because it’s return only 1 level nested comments. To get unlimited nested you need to use hierarchical arg as: $args = array( ‘parent’ => $comment_ID, ‘hierarchical’ => true, ); $questions = get_comments($args); Reference: … Read more

How to allow duplicate comments AND without comment text

WordPress will not allow you, using its default comment process, to insert empty comments into the database. This is enforced by wp_handle_comment_submission() with the following unconditional code: if ( ” == $comment_content ) { return new WP_Error( ‘require_valid_comment’, __( ‘<strong>ERROR</strong>: please type a comment.’ ), 200 ); } If you insist on using comments, you … Read more

if user role is then echo text

You are passing a role name, administrator, to current_user_can. Looking at the Codex page this is supported but not guaranteed to work, and should generally be avoided: Passing role names to current_user_can() is discouraged as this is not guaranteed to work correctly (see #22624). Instead, you should use a capability: if ( current_user_can( ‘manage_options’ ) … Read more

How to check if a comment has replies?

Here’s one example how to construct such a custom function: /** * Check if a comment has children. * * @param int $comment_id Comment ID * @return bool Has comment children. */ function has_comment_children_wpse( $comment_id ) { return get_comments( [ ‘parent’ => $comment_id, ‘count’ => true ] ) > 0; } using the get_comments() function … Read more

Ajax submit comments

you might find these links handy if you’re going to code it yourself http://byronyasgur.wordpress.com/2011/06/27/frontend-forward-facing-ajax-in-wordpress/ http://www.garyc40.com/2010/03/5-tips-for-using-ajax-in-wordpress/ I am fairly sure your URL is wrong url: “../wp-comments-post.php” – ajax in wordpress has to be sent (quite strangely) to/through admin-ajax.php (even if it’s not on the admin side). If you read the first link it is explained in … Read more