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 tie two conditions to one statement
- Create a page from different content blocks
- Content Restriction but allow public REST API
- How do test if a post is a custom post type?
- Enqueue Scripts / Styles when shortcode is present
- wp enqueue style on specific page templates
- How to rearrange fields in comment_form()
- Loading scripts only if a particular shortcode or widget is present
- Why isn’t is_page working when I put it in the functions.php file?
- How to conditionally enqueue a stylesheet only for a certain page(s)?
- Removing the “Website” Field from Comments and Replies?
- How to add a class to the comment submit button?
- How to wrap submit button of comment form with div
- how to create a conditional content_width for a wordpress theme?
- Comment Walker vs. Comment Callback
- How can I determine if a post has an image attachment?
- Display navigation menu item conditionally based on user capabilities
- comments reply script not working
- How to display comment form error messages in the same page
- How do I place content on archive pages but not on main page?
- Why does `add_theme_support( ‘html5’, array( ‘comment-form’ )` disable client side validation?
- Add class to Reply button in Comments area
- If Post Type equals, then display X content
- How do I set up real anonymous posting in bbpress forums? [closed]
- Display several random posts, but make sure a condition is met
- Why does comment_reply_link launch the reply form at the wrong spot on the comment section?
- How to allow the reply link to remain on the comment form after I have reached my 10 nested comment limit?
- Deep customization of the comment form?
- Custom Comments – Parent / Nested Reply
- Multisite Conditional (if blog_id?) in a page template?
- Using filter to add additional fields to comment_form()
- Show content after the first and second paragraph
- Why are default comments deprecated?
- Comments Reply Form
- Does WordPress Allow Blank/Empty Comment Submissions In WordPress?
- Show/hide Widgets in Dashboard Based on Current Advanced Custom Fields Option
- Comment form not display properly?
- Comment form not showing up without comments
- Add a Custom Field in Comment Box AFTER text area BUT BEFORE Send button
- How to display the_post_thumbnail if a post has one or otherwise display the first image in a post?
- Loading Javascript Only When Specific Content Existing in a Post?
- Programmatically block commenting by restricting view of comment form
- How to change submit button value in comment from “Post Comment” to “Send”
- Can shortcodes contain conditional statements? Even without them my shortcode renders blank page
- Hide comment form completely (preferably without using CSS)
- How can comments be submitted when I don’t have a comment box on a page?
- Rearrange elements outputted by comment_form()
- Display comment form of specific page in sidebar
- how to test for attached image
- comment_form() generates the wrong action url
- Show different different menu in theme_location depending on x
- Display only certain posts based on visitor’s country?
- Exclude custom function content from certain pages
- Add comments meta fields to comments metabox on post edit screen