Skip to content

Instantly share code, notes, and snippets.

@MrVibe
Created March 25, 2015 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MrVibe/ca17453361bc6ac5764e to your computer and use it in GitHub Desktop.
Save MrVibe/ca17453361bc6ac5764e to your computer and use it in GitHub Desktop.
Add custom stats in download stats section of Quiz
<?php
if(!class_exists('WPLMS_Customizer_Plugin_Class'))
{
class WPLMS_Customizer_Plugin_Class // We'll use this just to avoid function name conflicts
{
public function __construct(){
add_filter('wplms_download_mod_stats_fields',array($this,'custom_wplms_download_mod_stats_fields'),10,2);
add_action('wplms_mod_stats_process',array($this,'custom_wplms_mod_stats_process'),10,7);
} // END public function __construct
public function activate(){
// ADD Custom Code which you want to run when the plugin is activated
}
public function deactivate(){
// ADD Custom Code which you want to run when the plugin is de-activated
}
function custom_wplms_download_mod_stats_fields($fields,$type){
if($type == 'quiz'){
$fields['user_email'] = 'User Email';
}
return $fields;
}
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;
}
// ADD custom Code in clas
} // END class WPLMS_Customizer_Class
} // END if(!class_exists('WPLMS_Customizer_Class'))
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment