Get a user object by username or id javascript

(Ashesh Sen) #1

Is there any way to get a user object by username or id via javascript?

(David Taylor) #2

It is difficult to answer without some more context. You can always do this: (try it in the dev tools for Meta)

   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?

(Ashesh Sen) #3

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?

(David Taylor) #4

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.