Make WordPress Core

Opened 8 years ago

Last modified 4 months ago

#43885 new enhancement

WP_Role and WP_Roles::get_role() missing Display Name

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

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 7 years ago.
Add $display_name property to WP_Role class
43885.2.patch (765 bytes) - added by callumbw95 5 months ago.
Refreshed patch to resolve critical error

Download all attachments as: .zip

Change History (6)

@keraweb
7 years ago

Add $display_name property to WP_Role class

#1 @keraweb
7 years ago

  • Keywords dev-feedback has-patch added

#2 @keraweb
7 years ago

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

#3 @callumbw95
5 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
5 months ago

Refreshed patch to resolve critical error

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


4 months ago
#4

Note: See TracTickets for help on using tickets.