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

5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
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.