#6138 closed enhancement (fixed)
Member Types API: bp_has_user_member_type()
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 2.3 | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Members | Keywords: | has-patch |
| Cc: | lmoffereins@… |
Description
Since #6006 the Member Types API came available for developers. Since I'm trying to use this set of functions in conditionals for the current user, I propose an additional core function that checks for a (current) user's member types. See patch for an implementation for single or a set of member type names.
PS. I'm not familiar with unit testing yet, so I hope someone can jump in on that.
PPS. If I'm not mistaken, member types may be registered with label-like type names, i.e. they are not sanitized in any way within BP's functions. Hence checking for member types cannot be done with slug-like type names
Attachments (4)
Change History (11)
This ticket was mentioned in Slack in #buddypress by offereins. View the logs.
11 years ago
This ticket was mentioned in Slack in #buddypress by boone. View the logs.
11 years ago
This ticket was mentioned in Slack in #buddypress by boone. View the logs.
11 years ago
#5
@
11 years ago
- Keywords needs-unit-tests removed
Updated patch. I think it's better to support only single member type, like we do in other bp_*_member_type() functions.
Yes, let's do something like this for 2.3. I want to spend some more time thinking about the desired behavior of this function: you're referencing the *logged-in* user, but we don't have many functions like that in BP (and the ones that are are called
_loggedin_). Usually our template functions like this refer to the *displayed* user, or the current user in a template loop.You are correct that we're not running the
$member_typethroughsanitize_slug()likeregister_post_type()does - I'll open a separate ticket about that. However, I don't see what this has to do with checking "slug-like type names".in_array()in your proposed function will work fine in any case, right? Array keys can contain spaces and capital letters.