Home › Forums › Legacy Support › Support queries › How-to & Troubleshooting › Add custom user profile fields to statistic
Tagged: statistic v4
- This topic has 8 replies, 3 voices, and was last updated 3 years, 2 months ago by Anshuman Sahu.
Viewing 9 posts - 1 through 9 (of 9 total)
-
AuthorPosts
-
February 15, 2021 at 9:29 am #340233MarcoSpectatorHi, I have I would like to know if is possible in WPLMS version 4 to add more fields from user (like email address) and from profile (like first name and last name) to the statistics. I tryed 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/ Thank you, MarcoFebruary 16, 2021 at 8:51 am #340487DianaParticipantBefore: http://prntscr.com/zphen4 After: http://prntscr.com/zphqv0
Add this in wp-admin > Plugins > editor > Select WPLMS Customizer Plugin > wplms-customizer.phpadd_filter('wplms_course_stats_list','add_custom_course_stat'); add_action('wplms_course_stats_process','process_custom_course_stat',10,6); function process_custom_course_stat(&$csv_title, &$csv,&$i,&$course_id,&$user_id,&$field){ if($field != 'user_field') // Ensures the field was checked. return; $title=__('Location','vibe'); if(!in_array($title,$csv_title)) $csv_title[$i]=$title; $ifield = 'Location'; 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'; } function add_custom_course_stat($list){ $new_list = array( 'user_field1'=>'Location', 'user_field2'=>'Bio' //add another element like same above 'user_field3'=>'Gender' ); $list=array_merge($list,$new_list); return $list; }
February 16, 2021 at 1:25 pm #340556MarcoSpectatorDear Diana, thank you for suggestion, but I think that there is something wrong, I added the code in the wp-admin > Plugins > editor > WPLMS Customizer Plugin but only the labels are shown. In my profile fields I have the 2 fields "Nome" and "Cognome": https://prnt.sc/zqdtft Thank you for support, MarcoFebruary 17, 2021 at 12:11 pm #340792DianaParticipantThere is nothing wrong with the code, the field you are passing in the code to show there. make sure you have the same fields in the wp-admin > Users > profile fields So it can fetch some dataFebruary 17, 2021 at 12:57 pm #340802MarcoSpectatorDear Diana, I have fields in User > Profile Fields but in frontend nothing is displayed, I need to update something like buddypress navigation or permalinks? From your code I replaced "Location" with "Nome" that is my custom profile field name that students fill during the registration. The field is correctly filled if I look at the student profile, but in statistics is empty. Thank you for any suggestion!February 22, 2021 at 8:51 am #341724MarcoSpectatorDear Diana, I tryed a lot of times, also without any plugin ore code activated, but all the time the table with the custom fields are empty. Can you confirm that the solution works in version 4? Thank you for help. MarcoFebruary 23, 2021 at 1:03 pm #342007DianaParticipantThis reply has been marked as private.February 24, 2021 at 10:05 am #342148MarcoSpectatorDear Diana, do you have any update on this? Thank you, MarcoFebruary 25, 2021 at 12:25 pm #342388Anshuman SahuKeymastertry this :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( 'user_field1'=>'Location', 'nome'=>'Nome' //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 != 'nome') // Ensures the field was checked. return; $title=__('Nome','wplms'); if(!in_array($title,$csv_title)) $csv_title[$k]=array('title'=>$title,'field'=>'nome'); $ifield = 'Nome'; 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; $ccsv[$i]['nome'] = $field_val; }else{ $csv[$i][]= 'NA'; $ccsv[$i]['nome'] = 'NA'; } }
-
AuthorPosts
Viewing 9 posts - 1 through 9 (of 9 total)
- The topic ‘Add custom user profile fields to statistic’ is closed to new replies.