Those names are stored in the option wp_user_roles in the database table wp_options.
So, the following will change the name of the subscriber role:
$val = get_option( 'wp_user_roles' );
$val['subscriber']['name'] = 'PeDeBoi';
update_option( 'wp_user_roles', $val );
Apparently, this is harmless, but caveat emptor…
In your code, $wp_roles->roles[$role]['name'] = $new_role_name; doesn’t work because it should be:
$wp_roles->roles[$role_name]['name'] = $new_role_name;
And $display_name doesn’t make much sense.
Related Posts:
- Apply custom role capabilities to administrator (without plugin)
- Roles & capabilities GUI that does not create separate table
- How do I redirect upon login a specific user based on role?
- How to add another user to this remove_menu function?
- Add a new subscriber role using a function
- How to test for Super Admin
- Custom roles can’t access to wp-admin
- Custom registration URL lost when user makes signup mistake
- Custom function for specific user role
- Hide Author.php template from specific user role
- create shortcode to list users with specific meta key value
- Toggle User Roles with button
- How to change or add user role after getting post request data about pay? [closed]
- Execute a ultimate member action when user role is updated
- Allowing users to view private posts (pending approval)
- Allow Contributor to edit their own posts after Adm aproval
- How to add custom JavaScript in functions?
- How to set default post editor based on role?
- load CSS only for administrators on backend
- Adding additional roles on registration
- The Capability to choose post/page template
- How to add array [closed]
- Get users with different roles and call function on each of them (user_meta)
- How can I show different content for different user-levels?
- Custom user role still showing up after deletion, ideas?
- How to load a css file depending on the current role
- Allow user select role in wordpress default registration without plugin
- Remove check boxes and its label from screen option for custom role
- Add Change role button for list of user in an event
- How to show only specific category post by user role without plugin and restrict all other cats
- Change user role based on total number of items ordered
- Remove all video attachment, both files and post/postmeta from database?
- delete_user_meta for user in spesific group
- Change the second role depending on the first
- Restrict certain roles registrations by domain
- Multisite Admin Roles
- add_role menu pages are not visible
- Welcome Mails based on user role
- Get all users from role and add to dropdown (select) – wordpress, javascript
- Would it be possible to disable embeds for specific user roles? If so, how?
- How to make my logged-in user-role shortcode displaying name instead of slug?
- Best way of passing PHP variable between partials?
- Use author author display name in permalink structure for pages and posts
- Import WordPress XML File from Within Functions.php
- How do I create a new WP admin color scheme?
- Is it possible to use a forgot password url filter?
- how to make wordpress not to look for themes
- changing function wp_register
- What is user_trailingslashit() for?
- How to include all files within a folder to functions.php?
- Why is my Gutenberg block returning an error after initial save?
- Pass parameters to function through an action
- Remove Font-Awesome MaxCDN Link & Load Locally
- How to remove howdy dropdown menu content
- Change Admin Bar “Visit Site” URL
- exclude a category from a search on a specific page
- Stop turning small dashes into longer ones
- How to get specified parent page title in my function
- Execute function after a post has been published
- Last updated date function
- Possible to display shortcode based on the category?
- is_customize_preview() like function to check if Customizer “Live Preview” in JavaScript
- How to set default archive image without overriding first attached image? [closed]
- Passing a variable via wp_head and then calling it on the page
- Load Woocommerce and WordPress Functions Outside
- How to know which ajax file or function is called for action
- Option Tree integration of Custom CSS
- Deprecated function get_user_by_email($email)
- Don’t display html if function returns nothing
- Shortcode parse error – wrong syntax
- Load custom css in functions.php causing library issue
- In jquery use php variable to execute an enqueued jquery file
- Run a jquery script on on a certain template page
- Can’t add_action to ‘save_post’ and get it to fire
- How to load jQuery in TOP of wp_footer?
- How to fetch custom post type by variable date?
- How to make custom comment fields required
- two search forms on the same page
- Getting out side of wp root folder from function.php using absolute path
- How do I register a new settings page? [closed]
- Include Jquery libraries in wordpress theme?
- Strange error from functions.php files (wp_register_script)
- Retrieve First Image Function
- Display ACF category image on archive and single template files
- How to get taxonomy tree ids without running expensive loops
- Auto delete content in specific folder inside media library
- Using get_terms for custom taxonomy in functions.php
- How to update an image attachment’s alt text from a custom field when saving a post?
- Allow user only create specific tags
- Child theme remove parent filter in functions
- Set URL Parameter Post Layout As Default
- Enqueue JS + CSS via a child theme functions.php file?
- How to add publish/draft button in Admin Post Lists
- How to add number to wordpress count function?
- How do I integrate my Child Theme into a Custom Template?
- Sending Messages Back to the Template After Processing?
- Why are some custom javascript files working but some are not
- using enqueue_script in a shortcode isn’t working
- How to display milliseconds instead of seconds using timer_stop function? [closed]
- Filter to strip unnecessary attributes