$comment_id, 'comment_type' => 'academy_courses', ] ); if ( ! $academy_rating || $academy_rating > 5 ) { return; } // Same rule as the review AJAX route: only an enrolled student who // completed the course (or an administrator) can rate it. Anyone else's // comment stays a plain comment with no rating. $comment = get_comment( $comment_id ); $user_id = $comment ? (int) $comment->user_id : 0; if ( ! $user_id || ( ! user_can( $user_id, 'manage_options' ) && ! ( \Academy\Helper::is_enrolled( $comment_post_ID, $user_id ) && \Academy\Helper::is_completed_course( $comment_post_ID, $user_id ) ) ) ) { return; } if ( $academy_rating ) { add_comment_meta( $comment_id, 'academy_rating', $academy_rating, true ); } do_action( 'academy/frontend/after_course_rating', $comment_id, $comment_post_ID, $academy_rating ); }//end if } }