Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List all users does not get roles #266

Open
GuerrillaCoder opened this issue Aug 21, 2021 · 9 comments
Open

List all users does not get roles #266

GuerrillaCoder opened this issue Aug 21, 2021 · 9 comments

Comments

@GuerrillaCoder
Copy link

Currently doing:

var wpUsers = _client.Users.GetAll(useAuth:true).Result;

Will hit the endpoint:

https://example.com/wp-json/wp/v2/users

But this endpoint does not return users roles.

To return roles you need to pass edit context like so:

https://example.com/wp-json/wp/v2/users?context=edit

This needs to be an option on GetAll()

@GuerrillaCoder
Copy link
Author

I had a look at code and I think issue is IReadOperation. I think it needs to have a parameter for query params.

Let me know if you want a PR as it would update quite a few places in code.

@warp123
Copy link

warp123 commented Dec 31, 2023

Appart from the boolean "embed" property of the GetAll function, there should be an "edit" property in order to retrieve everything.
The problem resides in the httpHelper module. There should be an easy way to fix this, but i need to see if this messes the code in other places.

@hbcondo
Copy link

hbcondo commented Feb 6, 2024

Can the proposed "edit" property be applied to all the methods in the Users class? For example, it would beneficial to have the roles returned when calling GetCurrentUser. Right now it is null since this method does not have an embed property so AFAIK there is no way currently to get roles populated for the current user.

@hbcondo
Copy link

hbcondo commented Mar 5, 2024

@ThomasPe, is there a way this issue can be escalated? It's actually a blocker (for me) not being able to get roles via these User methods

@bindalf
Copy link

bindalf commented Mar 6, 2024

i would also need the roles for current user
downloaded code and edited
public Task GetCurrentUser()
{
return _httpHelper.GetRequestAsync($"{METHOD_PATH}/me?context=edit", true, true);
}

@ThomasPe
Copy link
Member

I'll try to look at this soon(ish)

@TREVORPINKS
Copy link

+1 - I would like this fix as well. It sounds like adding ?context=edit is all that is required (from non C# libraries)

https://stackoverflow.com/questions/46785783/wordpress-api-wont-return-all-users-fields

I am going to try to add Bindalf's update.

@TREVORPINKS
Copy link

https://github.com/TREVORPINKS/WordPressPCL/blob/master/WordPressPCL/Client/Users.cs This fixes the User.GetAllAsync method to return roles and all the other fields. I think the GetAllAsync method should default to TRUE/TRUE for the embed/auth params too. Because, I think most people would want all the fields by default. (and if they want performance they can play around with those other params).

@TREVORPINKS TREVORPINKS mentioned this issue Sep 21, 2024
@Firegarden
Copy link

My hero

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants