How to get the moderator role in bbPress

I don’t work with bbPress that much, but when I do – every time I spend most of my time hunting for functions. I wish there was some sort of documentation developed over the years, but it hasn’t, and I know, I know – I haven’t helped either. So at the very least, I decided to write down some of the common things I do with bbPress, starting with getting the moderator role.

It is really that simple:

current_user_can( 'moderate' )

That’s it. There is your answer.


How I found out

I browsed the source for quite a while, until I stumbled on a function called bbp_get_caps_for_role()


Ooh! Caps short for capabilities! I get it. That’s cool….when you know it.


I would never, ever, ever have┬ádiscovered┬áthat by guessing function names. I had to search files for the word “moderator” to eventually land on this piece of information.

Anyway. Now you know, and so do I. Caps are capabilities, and checking a moderator is as easy as current_user_can('moderate').

When you make stuff, please don’t save a few characters in function names by reducing capabilities to caps, unless it’s a standard practice, like “i18n” or “esc”.