Make WordPress Core

Opened 8 years ago

Last modified 6 days ago

#43885 new enhancement

WP_Role and WP_Roles::get_role() missing Display Name

Reported by: garrett-eclipse Owned by:
Priority: normal Milestone: Awaiting Review
Component: Role/Capability Version:
Severity: normal Keywords: dev-feedback has-patch needs-testing
Cc: Focuses:

Description

Hello,

While working with roles I found it odd that you can add a Display Name for a role but the WP_Role class and the WP_Roles function get_role don't provide this information.

Please add $display_name as a public attribute of WP_Role so it's available on that object and would be returned in the get_role function.

Thank you
P.S. Currently to access this information you have to use the WP_Roles as follows;

<?php
$wp_roles->roles[$role]['name'];

Attachments (2)

43885.patch​ (705 bytes ) - added by keraweb 8 years ago.
Add $display_name property to WP_Role class
43885.2.patch​ (765 bytes ) - added by callumbw95 15 months ago.
Refreshed patch to resolve critical error

Download all attachments as: .zip

Change History (7)

@keraweb
8 years ago

Add $display_name property to WP_Role class

#1 @keraweb
8 years ago

  • Keywords dev-feedback has-patch added

#2 @keraweb
8 years ago

Similar issue with different solution: https://core.trac.wordpress.org/ticket/34608

#3 @callumbw95
15 months ago

  • Keywords needs-testing added

Hey Everyone,

I have just taken a look into this, and it appears that the patch is causing an infinite loop which is caused by calling the WP_Roles class within the WP_Role class. As of such I have tweaked the patch to work using the global $wp_roles; variable instead.

I do feel like adding the display name to the WP_Role class is a long overdue feature, and it is somewhat odd how differently this class is set up compared to others within the codebase. Hopefully with this refreshed patch, and someone from the community confirming this is now working as intended, we can get this change into core soon. 😃

@callumbw95
15 months ago

Refreshed patch to resolve critical error

This ticket was mentioned in ​PR #9669 on ​WordPress/wordpress-develop by ​@dhruvang21.


13 months ago
#4

#5 @jamesbregenzer
6 days ago

Tested PR #9669 at 760d9df1251073281fd2e6e177c3045c488f50db against 64ede28c5d781d55cf017ca3f6f744da00e52bc8.
This independently confirms the current behavior with a separate test pass. Required build profile completed.
Relevant checks:

  • Required build profile completed.
  • Focused PHPUnit profile completed.
  • browser.wordpress-admin completed with.
Note: See TracTickets for help on using tickets.