Custom Fields in Course Stats not working

Home Forums Legacy Support Support queries How-to & Troubleshooting Custom Fields in Course Stats not working

Viewing 15 posts - 1 through 15 (of 24 total)
  • Author
    Posts
  • #235574
    ayalapau
    Spectator
    Hello, I've been trying to add 3 custom fields to the "download course stats" according to this forum post: https://wplms.io/support/knowledge-base/add-custom-user-field-in-download-course-stats/ This is my modified customizer_class.php:
    <?php   if(!class_exists('WPLMS_Customizer_Plugin_Class')){   class WPLMS_Customizer_Plugin_Class{     public function __construct(){   add_filter('wplms_course_stats_list',array($this,'add_custom_course_stat')); add_action('wplms_course_stats_process',array($this,'process_custom_course_stat'),10,6);         } // END public function __construct   function add_custom_course_stat($list){    $new_list = array(                     'user_field1'=>'Apellido Paterno',                     'user_field2'=>'Apellido Materno',                     'user_field3'=>'Sucursal del Promotor'                     //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) {   if( strpos($field, 'user_field1') === false  && strpos($field, 'user_field2') === false &&  strpos($field, 'user_field3') === false )      return;          if($field == 'user_field1'){        $title=__('Apellido Paterno','vibe');         if(!in_array($title,$csv_title))         $csv_title[$i]=$title;         $ifield = 'Apellido Paterno';         if(bp_is_active('xprofile'))        $field_val= bp_get_profile_field_data( 'field='.$ifield.'&user_id=' .$user_id );                          if(isset($field_val) && $field_val)         $csv[$i][]= $field_val;       else         $csv[$i][]= 'N.A';         return;      }   if($field == 'user_field2'){              $title=__('Apellido Materno','vibe');         if(!in_array($title,$csv_title))         $csv_title[$i]=$title;       $ifield = 'Apellido Materno';         if(bp_is_active('xprofile'))        $field_val= bp_get_profile_field_data( 'field='.$ifield.'&user_id=' .$user_id );                          if(isset($field_val) && $field_val)         $csv[$i][]= $field_val;       else         $csv[$i][]= 'N.A';         return;      }   if($field == 'user_field3'){              $title=__('Sucursal del Promotor','vibe');         if(!in_array($title,$csv_title))       $csv_title[$i]=$title;       $ifield = 'Sucursal del Promotor';         if(bp_is_active('xprofile'))        $field_val= bp_get_profile_field_data( 'field='.$ifield.'&user_id=' .$user_id );                          if(isset($field_val) && $field_val)         $csv[$i][]= $field_val;       else         $csv[$i][]= 'N.A';         return;      }            }       } // END class WPLMS_Customizer_Class } // END if(!class_exists('WPLMS_Customizer_Class'))   ?>   But when doing it, it will REPEAT the custom fields for every 2 users, this are the results: <pre style="caret-color: #000000; color: #000000; word-wrap: break-word; white-space: pre-wrap;">ID,NOMBRE,"Apellido Paterno","Apellido Materno","Sucursal del Promotor" 10,"Paula J",Ayala,Domínguez,Juriquilla 1,mnxelearn,Ayala,Domínguez,Juriquilla 9,CESAR,N.A,N.A,N.A 11,Ruben,N.A,N.A,N.A 13,Antonio,CAZARES,CE,HOUSTON 14,Inaki,CAZARES,CE,HOUSTON 12,Luis,Contreras,Soto,HOU 15,Santiago,Contreras,Soto,HOU 16,IVAN,Lopez,Perez,H-TOWN 17,BERTHA,Lopez,Perez,H-TOWN 18,ADRIANA,Suarez,Salinas,HOU 19,"Alejandro Armando",Suarez,Salinas,HOU 20,"MARTIN CARLOS",Osawa,Guerrero,Houston 21,"JOSE ARTURO",Osawa,Guerrero,Houston 22,"gabriela ivonne",Arias,Sartorius,"Monex Securities Houston" 23,"MARIA LETICIA",Arias,Sartorius,"Monex Securities Houston" 24,Carlos,Cazares,I,HOUSTON 25,David,Cazares,I,HOUSTON 26,Fabrizzio,PIÑA,RODRIGUEZ,"MERIDA YUCATAN" 27,Emilio,PIÑA,RODRIGUEZ,"MERIDA YUCATAN" 28,"JOSE MARIA",GARCIA,GARCIA,"MATRIZ MEXICO" 29,"DIANA ELENA",GARCIA,GARCIA,"MATRIZ MEXICO" 30,ANTONIO,"de Luna",Omaña,Leon 31,sofia,"de Luna",Omaña,Leon 32,alejandro,BENITEZ,SANCHEZ,MEXICALI 33,ALEJANDRA,BENITEZ,SANCHEZ,MEXICALI 34,"LUIS EDGAR",GARCIA,GARCIA,TORREON 35,ALFONSO,GARCIA,GARCIA,TORREON 36,"ZULEMA GUADALUPE",ruz,martinez,"playa del carmen" 37,"Teresa Yolanda",ruz,martinez,"playa del carmen" 38,karla,AGUAYO,RODRIGUEZ,LEON 39,ISELA,AGUAYO,RODRIGUEZ,LEON 40,"JESUS BERNARDO",Hernandez,Jasso,"Los Cabos" 41,"MARIA SUSANA",Hernandez,Jasso,"Los Cabos" 42,Gerardo,Villasenor,Lopez,"San Luis Potosi" 43,"julio cesar",Villasenor,Lopez,"San Luis Potosi" I'm getting right all the IDs and Name, but repeated custom fields... please help. Paula Ayala
    #235575
    ayalapau
    Spectator
    This reply has been marked as private.
    #235682
    logan
    Member
    Hello, please have a look here: https://docs.google.com/spreadsheets/d/14X7_qEb7sRIBufmUDKW8cQ_gdkX9UPGmjuFv5WWHMFs/edit?usp=sharing i could not find anything. please share:
    1. a video or screenshots with proper demarcation so that i can understand your issue.
    #235690
    ayalapau
    Spectator
    This reply has been marked as private.
    #235836
    Anshuman Sahu
    Keymaster
    please try adding this given code in your wplms-customizer.php file in wplms customizer plugin : https://gist.github.com/alexvibealex/3ab3b6fa3f36f533c565f06f442a94d1
    #235838
    ayalapau
    Spectator
    Hello Alex, thanks for your response, do I delete the other code from the customizer_class.php file? Thanks fo your help.
    #235843
    ayalapau
    Spectator
    Hello Alex, so I made some testing, here are the results:
    1. I had to make a little modification to your code, because as it was, it would send me a WP fatal error (the site wouldn't open): had to change: add_filter('wplms_course_stats_list','add_custom_course_stat')); add_action('wplms_course_stats_process','process_custom_course_stat1'),10,6); add_action('wplms_course_stats_process','process_custom_course_stat2'),10,6); add_action('wplms_course_stats_process','process_custom_course_stat3'),10,6);
    for: add_filter('wplms_course_stats_list',array($this,'add_custom_course_stat')); add_action('wplms_course_stats_process',array($this,'process_custom_course_stat1'),10,6); add_action('wplms_course_stats_process',array($this,'process_custom_course_stat2'),10,6); add_action('wplms_course_stats_process',array($this,'process_custom_course_stat3'),10,6); *** JUST ADDED THE " ,array($this, " part to each of these lines ****
    1. If I paste the code in the wplms_customizer.php file it won't work (I show you in the video)

    2. If I paste the code in the customizer_class.php file it will give me the same errors (duplicate information every 2 users ) I show you in the video.

    Link to the video: https://drive.google.com/open?id=1_y6LB50v6BvyfnnRUcp_-LLI8l1Son2n Thanks in advance for your help, Paula Ayala  

    #235887
    Anshuman Sahu
    Keymaster
    Hi yes the code is giving fatal error . I have modified and tested the code this time . https://gist.github.com/alexvibealex/3ab3b6fa3f36f533c565f06f442a94d1   Please remove the code you have in your customizer_class.php file and add it in wplms-customizer.php file at the end .  
    #235960
    ayalapau
    Spectator
    Hi Alex, thank you so much for your help, now it's working, except for the STARTING TIME (Fecha de Inicio), you can see that in the file generated, it's putting N.A. in all the users (starting at user with ID 14), can you help me with this? Thanks in advance,   Paula
    #235961
    ayalapau
    Spectator
    Hello Again, one additional thing I've noticed, the users that REPEATED the course (you can see them in BLUE in the image attached, are also "not showing" their end time (it's gone to N.A) I attach the image to show you this both issues: https://drive.google.com/open?id=12V230PqJtWfDK81WZWvjDznmKD142lU2   Thanks,
    #236034
    logan
    Member
    Hello, you ftp is not working at all:
    #236051
    ayalapau
    Spectator
    This reply has been marked as private.
    #236125
    logan
    Member
    This reply has been marked as private.
    #236223
    ayalapau
    Spectator
    Hello, thanks for your answer, I understand it was a holiday. You told me to remember you by monday (since I am in Mexico) I write to you on this hour, so you can be reminded. Thank you for your help in advance. Paula Ayala
    #236281
    logan
    Member
    Hello, i have tested this and the reason behind NA is there is no activity recorded in the course for the student Louis. have a look: http://prntscr.com/q88gij there is no start and finished date. its just started and ended up.
    are you deleting the activity or student deleted his activity??
Viewing 15 posts - 1 through 15 (of 24 total)
  • The topic ‘Custom Fields in Course Stats not working’ is closed to new replies.