bp_xprofile_get_selected_options_user_progress( array $settings )
Function will return the user progress based on the settings you provided.
Description
Parameters
- $settings
-
(Required) set of fieldset selected to show in progress & profile or cover photo selected to show in progress.
Return
(array) $response user progress based on widget settings.
Source
File: bp-core/bp-core-functions.php
function bp_xprofile_get_selected_options_user_progress( $settings ) {
$profile_groups = $settings['profile_groups'];
$profile_photo_type = $settings['profile_photo_type'];
// Get logged in user Progress.
$get_user_data = bp_get_user_meta( get_current_user_id(), 'bp_profile_completion_widgets', true );
if ( ! $get_user_data ) {
bp_core_xprofile_update_profile_completion_user_progress();
$get_user_data = bp_get_user_meta( get_current_user_id(), 'bp_profile_completion_widgets', true );
}
$response = array();
$response['photo_type'] = array();
$response['groups'] = array();
$response['total_fields'] = 0;
$response['completed_fields'] = 0;
$total_count = 0;
$total_completed_count = 0;
if ( ! empty( $profile_photo_type ) ) {
foreach ( $profile_photo_type as $option ) {
if ( 'profile_photo' === $option && isset( $get_user_data['photo_type'] ) && isset( $get_user_data['photo_type']['profile_photo'] ) ) {
$response['photo_type']['profile_photo'] = $get_user_data['photo_type']['profile_photo'];
$total_count = ++ $total_count;
if ( isset( $get_user_data['photo_type']['profile_photo']['is_uploaded'] ) && 1 === (int) $get_user_data['photo_type']['profile_photo']['is_uploaded'] ) {
$total_completed_count = ++ $total_completed_count;
}
} elseif ( 'cover_photo' === $option && isset( $get_user_data['photo_type'] ) && isset( $get_user_data['photo_type']['cover_photo'] ) ) {
$response['photo_type']['cover_photo'] = $get_user_data['photo_type']['cover_photo'];
$total_count = ++ $total_count;
if ( isset( $get_user_data['photo_type']['cover_photo']['is_uploaded'] ) && 1 === (int) $get_user_data['photo_type']['cover_photo']['is_uploaded'] ) {
$total_completed_count = ++ $total_completed_count;
}
}
}
}
if ( ! empty( $profile_groups ) ) {
foreach ( $profile_groups as $group ) {
if ( isset( $get_user_data['groups'][ $group ] ) ) {
$response['groups'][ $group ] = $get_user_data['groups'][ $group ];
$total_count = $total_count + (int) $get_user_data['groups'][ $group ]['group_total_fields'];
if ( isset( $get_user_data['groups'][ $group ]['group_completed_fields'] ) && (int) $get_user_data['groups'][ $group ]['group_completed_fields'] > 0 ) {
$total_completed_count = $total_completed_count + (int) $get_user_data['groups'][ $group ]['group_completed_fields'];
}
}
}
}
if ( $total_count > 0 ) {
$response['total_fields'] = $total_count;
}
if ( $total_completed_count > 0 ) {
$response['completed_fields'] = $total_completed_count;
}
/**
* Filters will return the user progress based on the settings you provided.
*
* @param array $response user progress array.
* @param array $profile_groups user profile groups.
* @param array $profile_photo_type user profile photo/cover data.
* @param array $get_user_data user profile cached data.
*
* @since BuddyBoss 1.5.4
*
*/
return apply_filters( 'bp_xprofile_get_selected_options_user_progress', $response, $profile_groups, $profile_photo_type, $get_user_data );
}
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.