How to make custom comment fields required and message field not required

Here is a related question that should answer yours. Basicly you want to use the pre_comment_on_post hook function custom_validate_comment() { //validate for brief and rating if( empty( $_POST[‘brief’]) || empty( $_POST[‘rating’]) ) wp_die( __(‘Error: you must fill in both the rating and the brief’) ); //make comment not required if(empy($_POST[‘comment’]){$_POST[‘comment’] == “empty_comment”;} } add_action(‘pre_comment_on_post’, ‘custom_validate_comment’); … Read more

How To Remove The “Click here to cancel reply” Link From The WordPress Comment Form

add_filter( ‘cancel_comment_reply_link’, ‘__return_false’ ); See /wp-includes/comment-template.php#function get_cancel_comment_reply_link() for more background. But if you do that the reply form will not move to the comment. The more interesting question is: Why doesn’t the link work for you? Do you have this line in your footer? is_singular() and get_option( ‘thread_comments’ ) and wp_print_scripts( ‘comment-reply’ );

One comment per user email per post

Try this, the code below will generate every comment by the $current_user->user_email for the author_email, if the $usercomment return something, then there is a comment by the current user so echo “thank you”, but if it’s not return anything output the form. global $current_user,$post; $usercomment = get_comments(array(‘author_email’ => $current_user->user_email, ‘post_id’ => $post->ID)); if($usercomment) { echo … Read more

Why are two functions over-riding each other?

It looks like you are overwriting the comment text with your commentimage_comment_text2 filter, try this to append the ratings text: add_filter( ‘comment_text’, ‘commentimage_comment_text2′ ); function commentimage_comment_text2( $comment ){ $rtt = “<br>Rating”; return $comment.$rtt; } ps: you forgot the $comment input parameter. Here is a poor man’s skematic picture of the filter flow in WordPress 😉 … Read more

How to add bubble count in WordPress wp_nav_menu menu?

For flexibility, you could assign the CSS bubblecount class to the corresponding menu item: and then target it with: if( in_array( ‘bubblecount’, (array) $item->classes ) ) $output .= ‘<span class=”unread”>’.my_function_here().'</span>’; in your code snippet above.

Get a variable field of all comments of current post

To get the comments use get_comments() and the current post’s ID. To get the URL fields only use wp_list_pluck(). To remove the empty fields use array_filter() without a callback. . $comment_urls = array (); $all_comments = get_comments( array ( ‘post_id’ => get_the_ID() ) ); if ( $all_comments ) { $comment_urls = array_filter( wp_list_pluck( $all_comments, ‘comment_author_url’ … Read more

where to modify get_comment_author_link()?

You would have to use the get_comment_author_link filter for this in the following manner. add_filter( “get_comment_author_link”, “wpse_63316_modifiy_comment_author_anchor” ); function wpse_63316_modifiy_comment_author_anchor( $author_link ){ return str_replace( “<a”, “<a target=”_blank””, $author_link ); }

Prevent Contributor to show comment list

Paste this code inside the functions.php file of your currently active theme. You can make it a plugin file too. It uses the “the_comments” filter to remove the unwanted comments from the backend table. /** * Filter out comments of other posts than current logged-in user. * * @param $all_comments all the comments to be … Read more