BP_Xprofile_Profile_Completion_Widget::get_user_progress_formatted( type $user_progress_arr )
Function formats user progress to pass on to templates.
Description
Parameters
- $user_progress_arr
-
(Required)
Return
(int)
Source
File: bp-xprofile/classes/class-bp-xprofile-profile-completion-widget.php
function get_user_progress_formatted( $user_progress_arr ) { /* Groups */ $loggedin_user_domain = bp_loggedin_user_domain(); $profile_slug = bp_get_profile_slug(); // Calculate Total Progress percentage. $profile_completion_percentage = round( ( $user_progress_arr['completed_fields'] * 100 ) / $user_progress_arr['total_fields'] ); $user_prgress_formatted = array( 'completion_percentage' => $profile_completion_percentage, ); // Group specific details $listing_number = 1; foreach ( $user_progress_arr['groups'] as $group_id => $group_details ) { $group_link = trailingslashit( $loggedin_user_domain . $profile_slug . '/edit/group/' . $group_id ); $user_prgress_formatted['groups'][] = array( 'number' => $listing_number, 'label' => $group_details['group_name'], 'link' => $group_link, 'is_group_completed' => ( $group_details['group_total_fields'] === $group_details['group_completed_fields'] ) ? true : false, 'total' => $group_details['group_total_fields'], 'completed' => $group_details['group_completed_fields'], ); $listing_number ++; } /* Profile Photo */ if ( isset( $user_progress_arr['photo_type']['profile_photo'] ) ) { $change_avatar_link = trailingslashit( $loggedin_user_domain . $profile_slug . '/change-avatar' ); $is_profile_uploaded = ( 1 === $user_progress_arr['photo_type']['profile_photo']['is_uploaded'] ); $user_prgress_formatted['groups'][] = array( 'number' => $listing_number, 'label' => $user_progress_arr['photo_type']['profile_photo']['name'], 'link' => $change_avatar_link, 'is_group_completed' => ( $is_profile_uploaded ) ? true : false, 'total' => 1, 'completed' => ( $is_profile_uploaded ) ? 1 : 0, ); $listing_number ++; } /* Cover Photo */ if ( isset( $user_progress_arr['photo_type']['cover_photo'] ) ) { $change_cover_link = trailingslashit( $loggedin_user_domain . $profile_slug . '/change-cover-image' ); $is_cover_uploaded = ( 1 === $user_progress_arr['photo_type']['cover_photo']['is_uploaded'] ); $user_prgress_formatted['groups'][] = array( 'number' => $listing_number, 'label' => $user_progress_arr['photo_type']['cover_photo']['name'], 'link' => $change_cover_link, 'is_group_completed' => ( $is_cover_uploaded ) ? true : false, 'total' => 1, 'completed' => ( $is_cover_uploaded ) ? 1 : 0, ); $listing_number ++; } /** * Filter returns User Progress array in the template friendly format. * * @since BuddyBoss 1.2.5 */ return apply_filters( 'xprofile_pc_user_progress_formatted', $user_prgress_formatted ); }
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.