Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Confused about filter bb_current_user_can


_ck_
Participant

@_ck_

Um, forum-moderators does exactly what you want, but it probably needs to be updated for 0.9 and 1.0

I have an unreleased plugin called “extra privileges” that does something like what you are asking but it won’t be released anytime soon.

You can see how filters on bb_current_user_can work by studying this mini-plugin I wrote to allow users to delete their own posts

function delete_own_post($retvalue, $capability, $args) {
global $bb_current_user, $bb_post;
if ($capability=="delete_post" && $bb_current_user->ID && $bb_post && $bb_post->post_id && $bb_post->post_id ==intval($args[1]) &&
$bb_post->poster_id && $bb_post->poster_id==$bb_current_user->ID && bb_current_user_can( 'edit_post', $bb_post->post_id) {return true;} // lots and lots of double checks
return $retvalue;
}
add_filter('bb_current_user_can', 'delete_own_post',10,3);

or simplier version:

function delete_own_post($retvalue, $capability, $args) {
if ($capability=="delete_post") {return bb_current_user_can( 'edit_post', $args[1]);}
return $retvalue;
}
add_filter('bb_current_user_can', 'delete_own_post',10,3);

Skip to toolbar