Is there any way to get a user object by username or id via javascript?
It is difficult to answer without some more context. You can always do this: (try it in the dev tools for Meta)
Discourse.User.findByUsername("David_Taylor").then(function(user){
console.log("User Found", user);
});
But that will result in an additional request to the server, which may not be necessary.
What are you trying to achieve?
Thanks very much. I am trying to get a list of usersnames with certain custom field attributes. As you correctly pointed out, it will result in many additional calls from the API.
Is it possible to achieve what I intend more gracefully?
If this is just for administrators, you might be able to utilise the data-explorer plugin. If you wanted this to work for all users, you would probably need to create a plugin which adds a new HTTP endpoint.
현재 구현 방식이 사용자 이름을 의존하고 있는 이벤트 플러그인 관련 버그 중 하나를 작업 중입니다. 이는 엣지 케이스이지만, 사용자 이름이 변경될 수 있으므로 id로 사용자를 조회할 수 있는 기능이 필요합니다.
핵심(core)에도 id로 사용자를 찾는 유사한 메서드가 있어야 한다고 생각합니다.
이 부분에 대해 여러분의 생각을 듣고 싶습니다.
플러그인은 사용자 이름이 변경될 때 사용자 이름 참조를 업데이트하거나, 데이터를 가져오기 위해 필요한 라우트와 직렬화기를 추가할 수 있어야 합니다.
현재 상황에서 이것이 가능한지 확인해 보겠습니다.
네. id로 사용자를 찾는 메서드를 UsersController에 추가하고, 이 새로운 컨트롤러 메서드를 호출하기 위해 Ember 쪽의 User 모델에도 메서드를 추가해야 합니다.