[wp-trac] [WordPress Trac] #19160: is_user_member_of_blog() gives unexpected results on single site

WordPress Trac wp-trac at lists.automattic.com
Sat Nov 5 11:09:35 UTC 2011


#19160: is_user_member_of_blog() gives unexpected results on single site
--------------------------+-----------------------
 Reporter:  duck_         |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  3.3
Component:  Users         |    Version:  3.1
 Severity:  normal        |   Keywords:  has-patch
--------------------------+-----------------------
 On single site with a logged in user:

 {{{
 var_dump( is_user_member_of_blog() ); // bool(false)
 }}}

 This is because when passed an empty $blog_id the function uses
 $wpdb->blogid as the current blog which is 0 in single site, but the blog
 ID set by get_blogs_of_user() is get_current_blog_id().

 Two possible solutions:

  1. Use get_current_blog_id()
  1. Return result of is_user_logged_in() if ! is_multisite()

 Attached patch for 1.

 is_blog_user() was included for single site in 3.1, see [15671], and
 didn't work as expected then either. It also caused a PHP notice as well
 as returning false.

 Also see #16702, especially [comment:ticket:16702:22 comment 21]. Noticed
 whilst writing patches for #19122.

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


More information about the wp-trac mailing list