Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have set up a wp multi-site with custom roles. One of the roles can add users. I need a solution to only show two roles available to the limited role on add user and leave all user types available to administrator. This code snipped works great for removing Administrator mode, but I don't understand enough of it to know if I could expand it to dis-clude other roles as well. Any help appreciated.

share|improve this question

1 Answer 1

Simple all you need to do is edit this part of the code :

function editable_roles( $roles ){
    if( isset( $roles['administrator'] ) && !current_user_can('administrator') ){
      unset( $roles['administrator']);
    }
    return $roles;
  }

and change it to

function editable_roles( $roles ){
    //don't change anything if current user is admin 
    if (current_user_can('administrator')) {
        return;
    }else{
        if( isset( $roles['administrator'] ) && !current_user_can('administrator') ){
           unset( $roles['administrator']);
           //here you add  "unset( $roles['role_to_remove']);" for each role you wish to remove
        }
    return $roles; 
  }
share|improve this answer
    
YOU are awesome! thanks a BUNCH - worked like a charm –  Ann Feb 5 '11 at 19:29
    
Glad i can help –  Bainternet Feb 5 '11 at 21:14
    
could this be used without the JPB_User_Caps class & in the functions.php? –  daniel Crabbe Jul 27 '11 at 12:17
    
Yep its WordPress functions so you should be able to use them in your functions.pho –  Bainternet Jul 27 '11 at 12:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.