[buddypress-trac] [BuddyPress] #1724: Hardcoded table prefix in get_blog_role_for_user

buddypress-trac at lists.automattic.com buddypress-trac at lists.automattic.com
Fri Jan 29 00:16:51 UTC 2010


#1724: Hardcoded table prefix in get_blog_role_for_user
------------------------+---------------------------------------------------
Reporter:  garrettmoon  |       Owner:     
    Type:  defect       |      Status:  new
Priority:  minor        |   Milestone:     
Keywords:               |  
------------------------+---------------------------------------------------

Comment(by garrettmoon):

 whoops, forgot to put that in a code block:

 {{{
 function get_blog_role_for_user( $user, $blog ) {

         global $wpdb, $current_blog;

         // If the user is a site admin, just display admin.
         if ( is_site_admin() )
                 return __( 'Admin', 'buddypress');

         $root_prefix = preg_replace('/' .
 preg_quote($current_blog->blog_id . '_', '/') . '$/', '', $wpdb->prefix);

         $roles = get_usermeta( $user, $root_prefix . $blog .
 '_capabilities' );

         if ( isset( $roles['subscriber'] ) )
                 $role = __( 'Subscriber', 'buddypress' );
         elseif  ( isset( $roles['contributor'] ) )
                 $role = __( 'Contributor', 'buddypress' );
         elseif  ( isset( $roles['author'] ) )
                 $role = __( 'Author', 'buddypress' );
         elseif ( isset( $roles['editor'] ) )
                 $role = __( 'Editor', 'buddypress' );
         elseif ( isset( $roles['administrator'] ) )
                 $role = __( 'Admin', 'buddypress' );
         else
                 return false;

         return $role;
 }
 }}}

-- 
Ticket URL: <http://trac.buddypress.org/ticket/1724#comment:1>
BuddyPress <http://buddypress.org/>
BuddyPress


More information about the buddypress-trac mailing list