Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.

Commit 30ea012

Browse files
committed
New method to validate the username
1 parent b1596f5 commit 30ea012

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

WordPressKit/AccountSettingsRemote.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,26 @@ public class AccountSettingsRemote: ServiceRemoteWordPressComREST {
9090
})
9191
}
9292

93+
/// Validate the current user's username
94+
///
95+
/// - Parameters:
96+
/// - username: The new username
97+
/// - success: block for success
98+
/// - failure: block for failure
99+
public func validateUsername(to username: String, success: @escaping () -> Void, failure: @escaping (Error) -> Void) {
100+
let endpoint = "me/username/validate/\(username)"
101+
let path = self.path(forEndpoint: endpoint, withVersion: ._1_1)
102+
103+
wordPressComRestApi.GET(path,
104+
parameters: nil,
105+
success: { responseObject, httpResponse in
106+
success()
107+
},
108+
failure: { error, httpResponse in
109+
failure(error)
110+
})
111+
}
112+
93113
public func suggestUsernames(base: String, finished: @escaping ([String]) -> Void) {
94114
let endpoint = "wpcom/v2/users/username/suggestions"
95115
let parameters = ["name": base]

0 commit comments

Comments
 (0)