function change_username_idc() { $old_username = 'old_username'; // Replace with the old username $new_username = 'new_username'; // Replace with the new username $new_nickname = 'default'; // Replace with the new nickname (set as 'default' to leave it unchanged) global $wpdb; $table_name = $wpdb->prefix . 'users'; $user = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $table_name WHERE user_login = %s", $old_username ) ); if ($user instanceof stdClass) { $result = $wpdb->update( $table_name, array( 'user_login' => $new_username, 'display_name' => $new_username, ), array('ID' => $user->ID), array('%s', '%s'), array('%d') ); if ($new_nickname !== 'default') { update_user_meta($user->ID, 'nickname', $new_nickname); } } } add_action('init', 'change_username_idc');