Opened 10 years ago
Closed 10 years ago
#5827 closed defect (bug) (no action required)
bp_is_user_profile() and bp_is_profile_component() return false on profile subpages
Reported by: | jreeve | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Core | Keywords: | |
Cc: |
Description
The docs for bp_is_profile_component()
and bp_is_user_profile()
say that they "Check whether the current page is part of the Profile component," and ask "Is the current page part of a user's extended profile?", respectively, yet if you run either of those functions on, say, /members/[username]/groups
, it returns false, since it uses bp_is_current_component()
, which returns groups
and not profile
or xprofile
. The bp_is_user_profile()
docs even give the example "/members/joe/profile/ (or a subpage thereof)," so it seems like its purpose would be to detect the root or parent component here.
Maybe the problem is one of consistency--when you run bp_current_component
on a profile subpage, it returns the name of the subpage, but when you run it on a groups subpage, e.g. /groups/testgroup/members, it returns the root component, i.e. "groups."
Change History (3)
#2
@
10 years ago
Ah, I get it. Thanks for the explanation. I was indeed confusing user pages and profile pages, since my /members/[username]
page displays the user profile. (It looks like this is a CBOX default.)
#3
@
10 years ago
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from new to closed
I was indeed confusing user pages and profile pages, since my /members/[username] page displays the user profile. (It looks like this is a CBOX default.)
Ah yes. I can see how this would be a bit confusing. Thanks again for the report!
Thanks for the report.
This is a semantic issue. From BP's point of view, the 'profile' component is only what you see when looking at your Extended Profile data. In a default installation, this is
/members/[username]/profile/
, but if you've changed the default component to be the xprofile, it would be/members/[username]/
.bp_is_user_profile()
will also return true when looking at subpages of the profile, such as/members/[username]/profile/edit/
.While pages like
/members/[username]/groups/
are part of a user's "profile" in the general sense that they're nested underneath a specific user, they are not part of the Profile component in BP's technical sense of the term.If you need a function to test whether you're looking at a user, try
bp_is_user()
(which returns a bool) orbp_displayed_user_id()
(which returns an int).Yes, you are correct that this is inconsistent. It dates from the very beginning of BuddyPress, and it'd be next to impossible to fix at this point without breaking every plugin :)
Does this make sense?