Opened 15 years ago
Closed 12 years ago
#11635 closed defect (bug) (fixed)
create a function that does this: wp_get_user_role()
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 3.6 | Priority: | normal |
Severity: | normal | Version: | 2.9 |
Component: | Role/Capability | Keywords: | has-patch close |
Focuses: | Cc: |
Description
There is an TODO task left in the file wp-admin/user-edit.php around line 196. The original author should decide wether or not he wants to implement the noted feature or to just drop it.
Related Code:
// Get the highest/primary role for this user // TODO: create a function that does this: wp_get_user_role() $user_roles = $profileuser->roles; $user_role = array_shift($user_roles);
Attachments (3)
Change History (20)
#5
@
15 years ago
- Keywords dev-feedback has-patch needs-testing added; developer-feedback has_patch needs_testing removed
#7
@
15 years ago
The patch works when is_user_logged_in() is false at least on my installation. I think it could warrant further tests, though, in case I missed something.
#8
@
15 years ago
- Component changed from General to Role/Capability
- Milestone changed from 3.0 to 3.1
Users can have multiple roles. There is no real way to determine which role is the "highest".
I'm proposing we leave this for 3.1, There are a few people who are wanting to clean roles up in 3.1
#11
@
13 years ago
I'll see your $user_id and raise you a $user object and then default to $current_user - also implemented the function in more places
#13
@
13 years ago
But other than that, I agree with dd32:
Users can have multiple roles. There is no real way to determine which role is the "highest".
#14
@
13 years ago
Semantics - return "first" role - the 3 or 4 places it is used were already arbitrarily returning the first role. I know multiple roles per user per blog exists, but I wish it didn't. Joining user_meta to subdivide users completely breaks at scale (over 1M users, many millions of rows of meta)
#15
follow-up:
↓ 16
@
12 years ago
- Keywords close added; dev-feedback needs-testing removed
- Milestone changed from Future Release to 3.6
I think the need for this is obsolete. I refreshed the function to return the first role or a passed role if the user has it. But it's only returning the label for the role ('administrator' etc). So the function only returns the first role or does the equiv of a current_user_can
- the TODO has been there since the beginning of time: http://core.trac.wordpress.org/browser/trunk/wp-admin/user-edit.php?rev=10935#L251 . Moving to 3.6 so it gets used or closed.
code was comitted by ryan.