bp_admin_repair_nickname_value()
Description
Source
File: bp-core/admin/bp-core-admin-tools.php
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.