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
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 | 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.