Add Multiple Users for WordPress
Issue with roles and custom role names (2 posts)

  1. David
    Posted 3 years ago #


    I've been using your plugin on a site that has bbPress installed as well as using the translation ability (i.e. filtering via 'gettext') to rename roles to something more relevant to the client. I've noticed that when displaying roles within AMU that it directly accesses the role_names variable of $wp_roles, and doesn't use the more correct get_editable_roles() or even better wp_dropdown_roles().

    Because of directly accessing the role names it ends up showing the bbPress roles (which it shouldn't do since bbPress 2.2 does them differently) and it also doesn't translate the role names of the WP roles.

    The relevant lines are as below:
    settings.php : lines 197, 202-205
    networkoptions.php : lines 340, 347-350, 392-395, 415-418
    commonfn.php : lines 26, 110-113

    Just thought this might help others.


  2. jrue
    Posted 3 years ago #

    Thanks David, this was great and helped me a lot. I ran into the same issues when using the co-authors plus plugin. The name property doesn't show up correctly, so it doesn't properly assign people to the correct user role and it appears that the new users aren't in the system (they are, but have no role associated with them.)

    Here are the code modifications I made:

    functions/settings.php line 201:

    //$roles = $wp_roles->get_names();
    $roles = get_editable_roles();

    then on line 205:

    foreach($roles as $key => $role) {
    	$thisrole = $key;

    In networkoptions.php I made pretty much the same modifications on line 340:

    //$roles = $wp_roles->get_names();
    $roles = get_editable_roles();


    foreach($roles as $key => $role) {
    	$thisrole = $key;


    foreach($roles as $key=>$role) {
    	$thisrole = $key;


    foreach($roles as $key=>$role) {
    	$thisrole = $key;

    in commonfn.php here is how I change the class around lines 26ish:

    global $wpdb, $wp_roles;
    $roles = get_editable_roles(); //$wp_roles->get_names();
    $tempnames = new stdClass();
    foreach($roles as $key => $role){
    	$tempnames->$key = $key;
    $this->lineroles = $tempnames;

    This mimicked the $wp_roles->get_names();, but with correct names.

    The key of the object has the correct role description which matches what's in the database for me, even with custom roles. The name property has something else. Not sure if this is a good way to go about this, but it worked for me and perhaps it might work for someone else. Adding users was a one-time deal for me, and I uninstalled the plugin after that.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Add Multiple Users for WordPress
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.