[wp-trac] [WordPress Trac] #10833: Cannot give users 'No role for this blog'

WordPress Trac wp-trac at lists.automattic.com
Wed Sep 23 17:47:07 UTC 2009


#10833: Cannot give users 'No role for this blog'
--------------------------+-------------------------------------------------
 Reporter:  TheDeadMedic  |       Owner:            
     Type:  defect (bug)  |      Status:  new       
 Priority:  normal        |   Milestone:  Unassigned
Component:  Users         |     Version:  2.8.4     
 Severity:  minor         |    Keywords:  has-patch 
--------------------------+-------------------------------------------------
 Blog admins cannot give users 'No role for this blog'.

 Problem lies in function '''get_editable_roles''', whereby if a role does
 not exist in the returned array, WordPress dies with the error "You can’t
 give users that role.".

 Proposed fix;


 {{{
 function get_editable_roles() {
         global $wp_roles;

         $all_roles = $wp_roles->roles;
         $editable_roles = apply_filters('editable_roles', $all_roles);

         // allow for no role
         $editable_roles[''] = true;

         return $editable_roles;
 }
 }}}

 However, this would also require a revision of '''wp_dropdown_roles''';


 {{{
 function wp_dropdown_roles( $selected = false ) {
         global $wp_roles;
         $p = '';
         $r = '';

         $editable_roles = get_editable_roles();

         foreach( $editable_roles as $role => $details ) {

                 // skip if blank (no) role
                 if ( empty($role) ) continue;

                 $name = translate_user_role($details['name'] );
                 if ( $selected == $role ) // Make default first in list
                         $p = "\n\t<option selected='selected' value='" .
 esc_attr($role) . "'>$name</option>";
                 else
                         $r .= "\n\t<option value='" . esc_attr($role) .
 "'>$name</option>";
         }
         echo $p . $r;
 }
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/10833>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list