Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Can functions in bp_template_tags.php be applied to a specific user ID?


Boone Gorges
Keymaster

@boonebgorges

@dwdutch
1) Exactly right.

2) Most (all?) BP-specific functions that default to the logged in user are named in a way that makes it clear. bp_loggedin_user_domain() is an example. There are some WP functions that take the logged in user as a default argument, and they’re generally not so helpfully named (fwiw the context is generally not so complex on a blog as it is in a BP network). current_user_can() is an example. When in doubt, I do a quick search through the codebase of a local installation. cd to the correct directory, and then grep -nR "function current_user_can" ./, etc.

While the functions in bp-x-templatetags.php generally don’t accept arguments in the normal way – they get their arguments from the context of the iterating bp_has_x loop – there are also some functions that take user ids (or group ids, or activity ids, etc) as arguments. For instance, have a look at bp-groups.php and groups_get_total_member_count() – this isn’t intended to be used in the context of a groups loop. Generally you’re going to be better off using a loop, as the api is really designed around this kind of use, but you can use these other functions to do some things without loops.

3) I used to use that phpxref on bp-dev.org all the time, but sadly it’s a version or two out of date, and is kind of useless at this point. (bp_has_members, for instance, used to be bp_has_site_members or something like that). If I had some spare time and bandwidth, I would set up an up-to-date phpxref of the current version of BP. In the meantime, I recommend following @r-a-y ‘s advice and going directly to the BP codebase, until the community has come up with a better solution

Skip to toolbar