package wordpress import ( "encoding/json" "federated.computer/wp-sync-slowtwitch/utilities" "net/url" ) type UserData struct { Id int `json:"id"` Username string `json:"username"` Email string `json:"email"` FirstName string `json:"first_name"` LastName string `json:"last_name"` } func GetUser(baseUrl, username, user, pass string) (UserData, bool) { endpoint := baseUrl + "/users?search=" + url.QueryEscape(username) body := utilities.GetHttpRequestToWordpress(endpoint, user, pass) var userData []UserData err := json.Unmarshal(body, &userData) if err == nil { for _, userData := range userData { if userData.Username == username { return userData, true } } } return UserData{}, false }