This will be the main code
global $current_user, $post;
$user_comment_count = get_comments(array('user_id' => $current_user->ID, 'post_id'=>$post->ID) );
if($user_comment_count) {
the_ratings();
} else {
comment_form(array('class_submit'=>'button'));
}
Also you may want to first check is the user is logged in with the is_user_logged_in()
Related Posts:
- wp_enqueue_script adding conditional statement not working
- Check if first paragraph is an image, then show custom code right after it?
- If post author role is X
- Can a conditional statement apply to part of a slug?
- Add default content to posts in a specific category?
- is_front_page, is_page(‘slug’), is_page(id) not working
- Need help on creating If-statement for custom meta fields
- How to make gravatar.com avatars conditional?
- Loading Scripts on Specific Pages
- Condition function for is parent category?
- Conditional Statement – Best Way to Remove Nav on Contact Page
- Proper syntax for simple conditional bloginfo language
- wordpress is_page() problem
- Location-Based Content
- Personalized message for each unique password-protected page
- Conditional Shortcode image display
- Change Woocommerce order button page on particular page
- Change a url / link if a user is logged in?
- to create own conditional tags for business directory in wp
- How to use “Cases” instead of “IFs” for conditional logic
- Which is the better way to write a conditional statement? [closed]
- Nested conditionals
- Is there a way to password-protect part of a post?
- if/Else have_posts Else fails to echo message to page
- Conditonal statement for iPad
- Return function only on certain pages
- How to write this conditional statement?
- Conditional for Custom Post Types
- Date-Based Conditional Tag
- Message box when accessed from iPad
- Insert a conditional in the middle of a function to give it 2 different outcomes
- How can I use ‘edit_form_after_title’ conditionally?
- Force Log in to view a page
- Conditional loading of CSS for my plugin
- Looks like this if condition is not working [closed]
- Generating images from an array of categories
- WP conditional site logo and header block
- How to know if the most recent article
- Widget logic conditional widget
- How to display image on condition that a selection has been made
- How to Conditionally Not Display a Link Based on Current URL?
- Allow users to only CREATE one single (custom) post
- If statement to check for post_content
- why is my custom loop failing?
- Conditional sidebar menu
- What is the best way to disable my WP website if the user has adblocker on? [closed]
- How to rearrange fields in comment_form()
- Removing the “Website” Field from Comments and Replies?
- Show/hide Widgets in Dashboard Based on Current Advanced Custom Fields Option
- Add a Custom Field in Comment Box AFTER text area BUT BEFORE Send button
- comment_form() generates the wrong action url
- Use Hooks to Limit One Comment Per User Per Post – Hide Form if Already Commented
- Making a Comment on a page without being on that page?
- How to hide and content from auto-generated excerpts?
- Alternate text if shortcode returns no data
- How to do conditional publishing?
- Show comments fields in two columns
- Default comments file and how to copy it
- A function like is_page() but returns true if on any sub page of given page
- Auto-fill Custom comment fields
- Add class to comment form div when comment-reply button is clicked
- Jetpack Comments with fall-back
- Plugin Code ONLY on Post Edit Page
- Display complete comment section via post ID
- Prevent update of custom user profile meta field on the front end after 1st entry
- How to retain comment text on comment form after login/registration?
- Highlight comments of all the site authors
- How to jump to newly posted comment anchor after submit?
- Conditional for a Single Post That Belongs to a Category?
- Dynamically output a class to an anchor tag depending on what tag is chosen
- Why could my comment_form variable not be working?
- FacetWP – conditionally display facet labels
- WordPress comment submit button substitutes/options
- Why might conditionals not work on a page?
- NextGEN Conditional Statement [closed]
- How To Detect Posted Comment in Theme Development?
- Use of comment_reply_link_args filter
- Can I set up a hover animation in CSS depending on a PHP conditional?
- Comment form on custom page template
- Add comment_meta to wp_comment_reply
- If user is logged in and has a role echo statement
- Banner appearing on Pages but not Posts; call it conditional confusion
- How to filter comments by comment_meta
- How do I make content only load on desktop? [duplicate]
- How to display replies to his comments in user profile of current user
- Top rated posts Average rating issue
- Modify wp-login.php Labels Conditionally Based On Referring URL
- Show code only on WooCommerce Pages
- Conditional: IF current author’s custom post has a post thumbnail
- How to add a class to comment submit button?
- Php conditional help needed
- functions.php conditional output for a single plugin
- Need an advice about comments
- How do I add a nested conditional within an echo – to use a default image if there isn’t one in the post?
- In my comment form, how do I move the “notify me of follow-up comments” box above the “post comment” button?
- strange conditional tag behaviour [duplicate]
- Weird html output of single_cat_title – is not inside of the html element?
- Questions about using Disqus or Jetpack for comments [closed]
- How to set up a echo? [closed]
- Dynamic Buttons According to URL parameter