#16702 closed defect (bug) (fixed)
is_blog_user() bug on Multisite
Reported by: | MattyRob | Owned by: | ryan |
---|---|---|---|
Milestone: | 3.3 | Priority: | normal |
Severity: | normal | Version: | 3.0 |
Component: | Multisite | Keywords: | dev-feedback |
Focuses: | Cc: |
Description
I've just installed a fresh WordPress 3.1 with Multisite enable and configured and there seems to be a glitch in is_blog_user().
It looks for a capability with a key name of the site prefix . blog_id . _capabilties.
But, the first installed blog on an MU site is installed without the blog_id in the key name.
On my test site for example I have a the main site WPMU and 2 sub site Test1 and Test2.
In the usermeta table there are capability keynames as follows:
wpmu_capabilities (relating the my WPMU site)
wpmu_1_capabilities (relating to Test1)
wpmu_2_capabilities (relating to Test2)
So, is_blog_user() returns false for all users of WPMU as the function is looking for the wrong key name.
Attachments (6)
Change History (27)
#4
@
13 years ago
- Keywords needs-refresh dev-feedback added
Switched to using get_blogs_of_user() as suggested, all works fine.
+1 to commit the proposed patch, deprecate is_blog_user() and close this ticket.
#5
@
13 years ago
- Keywords needs-refresh removed
- Milestone changed from Awaiting Review to 3.3
Refreshed for 3.3.
#6
follow-up:
↓ 7
@
13 years ago
Let's keep this as a wrapper for get_blogs_of_user(). We can deprecate later when we are energetic enough to come up with a better name.
#9
@
13 years ago
- Owner set to ryan
- Resolution set to fixed
- Status changed from new to closed
In [19004]:
#11
@
13 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
There's another function: is_user_member_of_blog() which is already a wrapper around get_blogs_of_user().
#12
@
13 years ago
- Keywords has-patch removed
We should deprecate one or the other. is_blog_user() is shorter, but is_user_member_of_blog() is more descriptive. Coin toss?
#13
follow-up:
↓ 14
@
13 years ago
We can make is_blog_user() a wrapper for is_user_member_of_blog(), since the later requires a user id.
#14
in reply to:
↑ 13
@
13 years ago
Replying to scribu:
We can make is_blog_user() a wrapper for is_user_member_of_blog()
That's what I initially was going to do, but that function seems to be only available in Multisite, while is_blog_user()
is available on a single site too.
#15
@
13 years ago
Well, both functions come from MU. It's silly to have one available all the time and one only for multisite.
IMO, we should make is_user_member_of_blog() available all the time.
#17
follow-up:
↓ 18
@
13 years ago
I forgot about is_user_member_of_blog(). Move it to user.php, make is_blog_user() wrap it, and deprecate is_blog_user(). How's that sound?
#18
in reply to:
↑ 17
@
13 years ago
Replying to ryan:
I forgot about is_user_member_of_blog(). Move it to user.php, make is_blog_user() wrap it, and deprecate is_blog_user(). How's that sound?
Done in 16702.4.patch.
#19
@
13 years ago
Let's also make $user_id for is_user_member_of_blog() default to 0, thus the current user. Then someone could call is_user_member_of_blog()
and be told about the current user's relationship to the current blog. Basically identical to is_blog_user() now but a bit more flexible in the long run.
Yeah, we should be using $wpdb->get_blog_prefix() there.
It looks like it's @since MU, rather than 3.0. I'd recommending using get_blogs_of_user() then look through that, for now. We don't use this function in core and I'd be inclined to deprecate it simply for its simply horrible name.