Add custom user profile fields to statistic

Home Forums Legacy Support Support queries How-to & Troubleshooting Add custom user profile fields to statistic

Tagged: 

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #378287
    induscorp
    Participant
    Hi, I want to add more fields from the user (like email address) and All Extended Profile (like Phone, SOL ID, EMP ID, ZONE, BRANCH NAME, and DESIGNATION) to statistics. I tried all the code tips in the forum but didn't work and the values are empty https://wplms.io/support/knowledge-base/add-custom-user-field-in-download-course-stats/ https://wplms.io/support/knowledge-base/add-a-custom-information-in-course-stats-download-report/ Regards Mahi
    #378363
    Veronica
    Moderator
    hi can you please confirm the version of the theme
    #378442
    induscorp
    Participant
    WPLMS 4.097
    #378490
    Veronica
    Moderator
    hi you need to use this code:
    add_action('wplms_course_stats_process','process_custom_course_stat',10,8);
    add_filter('wplms_course_stats_list','add_custom_course_stat');
    
     function add_custom_course_stat($list){
       $new_list = array(
                        'email'=>'Email'
                        //add another element like same above 'user_field3'=>'Gender'
                         );
       
       $list=array_merge($list,$new_list);
        return $list;
    }
              
    function process_custom_course_stat(&$csv_title, &$csv,&$i,&$course_id,&$user_id,&$field,&$ccsv,&$k){
      if($field != 'email') // Ensures the field was checked.
         return;
    
        $title=__('Email','wplms');
    	if(!in_array($title,$csv_title))
    	 $csv_title[$k]=array('title'=>$title,'field'=>'Email');
    		$ifield = 'Email'; 
    		$user = get_user_by('id',$user_id);
    		
      	$field_val = $user->data->user_email;
       		
    	if(isset($field_val) &&  $field_val){
    	  
       		$csv[$i][]= $field_val;
          	$ccsv[$i]['Email'] =  $field_val;
    	   
        }else{
    
          $csv[$i][]= 'NA';
          $ccsv[$i]['Email'] = 'NA';
        }
    	
    
    }
    change the field name accordingly here in the code Email fields is added
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.