bp_xprofile_get_user_progress_formatted( array $user_progress_arr )
Function formats user progress to pass on to templates.
Description
Parameters
- $user_progress_arr
-
(Required) - raw details to calculate user progress
Return
(array) $user_prgress_formatted - user progress to render profile completion
Source
File: bp-xprofile/bp-xprofile-functions.php
2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 | function bp_xprofile_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 ); } |
Changelog
Version | Description |
---|---|
BuddyBoss 1.4.9 | Introduced. |
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.