Home › Forums › Legacy Support › Support queries › How-to & Troubleshooting › Custom Fields in Course Stats not working
- This topic has 23 replies, 3 voices, and was last updated 4 years, 4 months ago by logan.
-
AuthorPosts
-
December 3, 2019 at 1:18 am #235574ayalapauSpectatorHello, 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 AyalaDecember 3, 2019 at 1:19 am #235575ayalapauSpectatorThis reply has been marked as private.December 3, 2019 at 12:55 pm #235682loganMemberHello, please have a look here: https://docs.google.com/spreadsheets/d/14X7_qEb7sRIBufmUDKW8cQ_gdkX9UPGmjuFv5WWHMFs/edit?usp=sharing i could not find anything. please share:- a video or screenshots with proper demarcation so that i can understand your issue.
December 3, 2019 at 2:06 pm #235690ayalapauSpectatorThis reply has been marked as private.December 4, 2019 at 2:42 pm #235836Anshuman SahuKeymasterplease try adding this given code in your wplms-customizer.php file in wplms customizer plugin : https://gist.github.com/alexvibealex/3ab3b6fa3f36f533c565f06f442a94d1December 4, 2019 at 2:47 pm #235838ayalapauSpectatorHello Alex, thanks for your response, do I delete the other code from the customizer_class.php file? Thanks fo your help.December 4, 2019 at 3:33 pm #235843ayalapauSpectatorHello Alex, so I made some testing, here are the results:- 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);
- If I paste the code in the wplms_customizer.php file it won't work (I show you in the video)
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
December 5, 2019 at 5:42 am #235887Anshuman SahuKeymasterHi 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 .December 5, 2019 at 2:01 pm #235960ayalapauSpectatorHi 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, PaulaDecember 5, 2019 at 2:20 pm #235961ayalapauSpectatorHello 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,December 6, 2019 at 10:42 am #236034loganMemberHello, you ftp is not working at all:December 6, 2019 at 12:57 pm #236051ayalapauSpectatorThis reply has been marked as private.December 7, 2019 at 12:36 pm #236125loganMemberThis reply has been marked as private.December 9, 2019 at 4:40 am #236223ayalapauSpectatorHello, 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 AyalaDecember 9, 2019 at 10:38 am #236281loganMemberHello, 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?? -
AuthorPosts
- The topic ‘Custom Fields in Course Stats not working’ is closed to new replies.