Confused about filter bb_current_user_can
It’s not the first time and it won’t be the last. I’m confused.
I’m trying to add forum moderator capabilities to the currently logged in user in a specific forum only. I don’t want to give them the moderator role. I just need to give them additional caps in a specific forum. When the user is tooling ’round in the forum I want to give mod rights to, assign them dynamicly. When they are no longer in that forum, take ‘em away on the fly.
If found a couple of things to guide me. One was forum-moderators.php by Aditya Naik. This give specific users a forum moderator role thru the bbpress backend. That stores the rights to those caps as a meta value and assigns them when the user is on the forums. Great. There’s a fn in there that determines what forum the user is in and responds to a filter called ‘bb_user_has_cap’. I can’t find neither hide nor hair of using this filter anywhere except in a couple of plugins by sambauers. http-authentication and ldap-authentication.
So, I found the filter ‘bb_current_user_can’. It looks to me like everyone on the planet is using this filter. The comment in the fn bb_currrent_user_can() says use ‘bb_user_has_cap’. Well, nothing is using that as far as I can determine.
Anyway, my confusion comes in when I try to implement my filter. I’m gonna give the user the following caps:
$forum_mod_caps = array(
For me, reading the code for bb_current_user_can() is like the time I got curious about implementing tcp/ip for the Atari ST. I got a headache. My skill level is not up to understanding what is going on down there. Some guidance would be appreciated.
We have 3 args to this filter:
$retvalue, $capability, $args
Looks like $retvalue is being passed up the filter chain. If I don’t want to touch the call I just pass $retvalue back.
I was digging ’round and looks like $capabilities is the cap being queried. $args is specific to each call and may vary depending on what cap is queried.
These are questions in case you haven’t noticed. My understanding breaks down when I get to what I’m being passed and what I’m supposed to do with them other than return ‘true’ if it’s a cap I want to let the user have.
I should just return true if it’s a cap I want the user to have. It’s up to me to determine if it’s appropriate at their location in the universe. Yes?
You must be logged in to reply to this topic.