bp_admin_repair_nickname_value()

Description

Source

File: bp-core/admin/bp-core-admin-tools.php

1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
function bp_admin_repair_nickname_value() {
 
    $offset = isset( $_POST['offset'] ) ? (int) ( $_POST['offset'] ) : 0;
 
    $args  = array(
        'number' => 50,
        'fields' => array( 'ID' ),
        'offset' => $offset,
    );
    $users = get_users( $args );
 
    if ( ! empty( $users ) ) {
 
        foreach ( $users as $user ) {
            $nickname = xprofile_get_field_data( bp_xprofile_nickname_field_id(), $user->ID );
            if ( preg_match( '/[A-Z]/', $nickname ) ) {
                xprofile_set_field_data(
                    bp_xprofile_nickname_field_id(),
                    bp_loggedin_user_id(),
                    strtolower( $nickname )
                );
            }
            $offset++;
        }
        $records_updated = sprintf( __( '%s members updated successfully.', 'buddyboss' ), number_format_i18n( $offset ) );
        return array(
            'status'  => 'running',
            'offset'  => $offset,
            'records' => $records_updated,
        );
    } else {
        // Description of this tool, displayed to the user.
        $statement = __( 'Repair Nickname… %s', 'buddyboss' );
        $result    = __( 'Complete!', 'buddyboss' );
 
        // All done!
        return array(
            'status'  => 1,
            'message' => sprintf( $statement, $result ),
        );
    }
 
}

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.