Group-scoped Moderation
By default, only users with the global wcb_moderate_jobs ability can
approve or reject pending jobs. On a community site that’s usually just
admins.
When a BP group has its own job board, that gate is too strict - group admins want to review jobs posted to their group without you having to grant them site-wide moderator powers.
This integration adds an exemption: BP group admins and moderators can approve / reject pending jobs on their group’s board only.
How it works
Section titled “How it works”Free exposes a hookable ability check that passes the result and the job being acted on:
$allowed = apply_filters( 'wcb_moderate_jobs_ability_check', $allowed, $job_id );Pro hooks this filter via BpGroupBoards::allow_group_admins_to_moderate()
with two arguments ($allowed, $job_id). For each pending-job
moderation request it:
- Returns early if access is already allowed, the job id is 0, or the BP Groups functions are unavailable.
- Reads the current user with
get_current_user_id()- bails for logged-out users. - Loads the job’s
_wcb_board_idpost-meta - bails if 0. - Loads that board’s
_wcbp_group_idpost-meta - bails if 0 (the board isn’t linked to a group). - Returns
trueif the user is an admin or mod of that group (groups_is_user_admin/groups_is_user_mod).
The check is job-scoped through the job’s own board, so a group admin in group A cannot moderate jobs posted to group B.
What’s covered
Section titled “What’s covered”| Action | Group admin can do it? |
|---|---|
| Approve / publish a pending job on their group’s board | Yes |
| Reject a pending job on their group’s board | Yes |
| Moderate a job on a different group’s board | No |
| Moderate a site-wide pending job (not on any group’s board) | No |
The exemption only loosens the wcb_moderate_jobs ability check for
group-board jobs; it does not create a new admin screen. Group admins
moderate the same way any moderator does - through the moderation surface
Free provides - but the ability check now says yes for jobs on their own
group’s board.
Disabling the exemption
Section titled “Disabling the exemption”To keep moderation strictly global (only users with wcb_moderate_jobs
can approve, even group admins), remove the filter from the
BpGroupBoards instance:
remove_filter( 'wcb_moderate_jobs_ability_check', array( 'WCB\Pro\Integrations\Buddypress\BpGroupBoards', 'allow_group_admins_to_moderate' ) );Auditing approvals
Section titled “Auditing approvals”Approvals fire wcb_job_approved regardless of which user approved. To
log who approved a group-board job, read the same two meta keys the
integration uses:
add_action( 'wcb_job_approved', function ( $job_id ) { $approver_id = get_current_user_id(); $board_id = (int) get_post_meta( $job_id, '_wcb_board_id', true ); $group_id = (int) get_post_meta( $board_id, '_wcbp_group_id', true ); if ( $group_id ) { // Log: $approver_id approved $job_id on group $group_id }} );
