Add custom field in Download Stats for Quiz/Assignment/Units/Question ..

0. Install WPLMS customiser plugin.

1. Go to WP Admin -> Plugins ->Editor -> Wplms customizer -> customizer_class.php

2. Add this code in __construct function :

Assuming the custom user field is Location :

add_filter('wplms_download_mod_stats_fields',array($this,'custom_wplms_download_mod_stats_fields'),10,1);
add_action('wplms_mod_stats_process',array($this,'custom_wplms_mod_stats_process'),10,7);

3. Add this code in the class :

  function custom_wplms_download_mod_stats_fields($list){
         $list['user_email']= 'Student Email';
         return $list;
        }

function custom_wplms_mod_stats_process(&$csv_title, &$csv,&$i,&$id,&$user_id,&$field,&$post_type){
            if($post_type != 'quiz')
                return;
            if($field != 'user_email') // Ensures the field was checked.
             return;
 
            $title=__('Student Email','vibe');
            if(!in_array($title,$csv_title))
              $csv_title[$i]=$title;
       
            $user = get_userdata( $user_id );
            $csv[$i][]= $user->user_email;
        }

 

 

Result :

 

 

gist : https://gist.github.com/MrVibe/ca17453361bc6ac5764e