Title: Student lists plugin
Last modified: April 26, 2024

---

# Student lists plugin

 *  [satisfactionstate](https://wordpress.org/support/users/satisfactionstate/)
 * (@satisfactionstate)
 * [2 years, 1 month ago](https://wordpress.org/support/topic/student-lists-plugin/)
 * Hello dear developers. I thought that it would be very useful for the student
   lists plugin to show those students who are not enrolled in the course. It is
   optional for others, but for small universities it is important – so you can 
   calculate truant students. This is a useful functionality.
 *     ```wp-block-code
       <?php
       //total in progress      
       $finishedCount = 0;
       $inProgressCount = 0;
       $nonEnrolledStudents = [];
   
       foreach ($students as $student) {
           $student = learn_press_get_user($student->ID);
           $course_data = $student->get_course_data($course->get_id());
   
           if (!$course_data) {
               $nonEnrolledStudents[] = $student->user_email;
           } else {
               $course_results = $course_data->get_results(false);
               $result = $course_results['result'];
   
               if ($result == 100) {
                   $finishedCount++;
               } else {
                   $inProgressCount++;
               }
           }
       }
   
       echo "Finished: " . number_format(($finishedCount / count($students)) * 100, 2) . "%<br>";
       echo "In Progress: " . number_format(($inProgressCount / count($students)) * 100, 2) . "%<br>";
   
       $nonEnrolledSubscribers = [];
   
       // Get all subscribers who are not enrolled in the course
       $args = array(
           'role' => 'subscriber',
           'meta_key' => 'lp_enrolled_courses',
           'meta_compare' => 'NOT EXISTS'
       );
       $subscribers = get_users($args);
   
       foreach ($subscribers as $subscriber) {
           $nonEnrolledSubscribers[] = $subscriber->user_email;
       }
   
       echo "<table border='1' id='subscriberTable'>";
       echo "<tr><th>Email</th></tr>";
   
       foreach ($nonEnrolledSubscribers as $subscriberEmail) {
           echo "<tr><td>" . $subscriberEmail . "</td></tr>";
       }
   
       echo "</table>";
       echo "<button onclick='exportToExcel()'>Export to Excel</button>";
   
       echo "<script>
           function exportToExcel() {
               const table = document.getElementById('subscriberTable');
               let html = table.outerHTML;
               const url = 'data:application/vnd.ms-excel,' + encodeURIComponent(html);
               const a = document.createElement('a');
               a.href = url;
               a.download = 'subscribers.xls';
               a.click();
           }
       </script>";
       //total in progress finish
       ?>
       ```
   
 * I found a taemplate plugin that is responsible for displaying the list of students
   who came and after the ul tag I insert my code, but it just shows the list of
   all subscribers, but I would like it to be those subscribers or in general all
   users except admins, who did not come / did not sign up for the course. It would
   also be useful to display an overall picture of the course – who is in progress
   and who has finished, so that you don’t have to count manually. My code doesn’t
   work, apparently I’m getting the values wrong. I am not strong in code for writing
   plugins. If you have a chance, please tell me what I’m doing wrong. Thank you
   in advance for any advice!

The topic ‘Student lists plugin’ is closed to new replies.

 * ![](https://ps.w.org/learnpress/assets/icon-256x256.gif?rev=3254420)
 * [LearnPress - WordPress LMS Plugin for Create and Sell Online Courses](https://wordpress.org/plugins/learnpress/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/learnpress/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/learnpress/)
 * [Active Topics](https://wordpress.org/support/plugin/learnpress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/learnpress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/learnpress/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [satisfactionstate](https://wordpress.org/support/users/satisfactionstate/)
 * Last activity: [2 years, 1 month ago](https://wordpress.org/support/topic/student-lists-plugin/)
 * Status: not resolved