Thread Starter
joeco
(@joeco)
Hello,
Please respond, resolving this issue is very important for us.
Thank you!
Hi there,
Sorry for the delay getting back to you.
There is an example in the docs here: https://sites.google.com/digitalarm.co.uk/bbpress-moderation-tools/#h.p_oPCkdsaEEdIV
I think you’re looking for something more like this:
add_filter( 'bbp_modtools_moderate_post', 'foo_whitelist_users', 10, 2 );
function foo_whitelist_users( $pending, $post ) {
// Whitelist a user by ID
if ( 8 === get_current_user_id() ) {
$pending = false;
}
return $pending;
}
You could also get the current user and allow certain roles. Does that help?
-
This reply was modified 7 years, 1 month ago by
Digital Arm.
Thread Starter
joeco
(@joeco)
Hello,
How would I add more users to the whitelist? Is the following correct?
function foo_whitelist_users( $pending, $post ) {
// Whitelist a user by ID
if ( 8 === get_current_user_id() ||
82 === get_current_user_id() ||
118 === get_current_user_id() ) {
$pending = false;
}
return $pending;
}
Thread Starter
joeco
(@joeco)
oops, try this:
`add_filter( ‘bbp_modtools_moderate_post’, ‘foo_whitelist_users’, 10, 2 );
function foo_whitelist_users( $pending, $post ) {
// Whitelist a user by ID
if ( 8 === get_current_user_id() ||
82 === get_current_user_id() ||
118 === get_current_user_id() ) {
$pending = false;
}
}’
You could use an array to keep things a bit cleaner, like this:
// Allow all posts by users by id
add_filter( 'bbp_modtools_moderate_post', 'foo_whitelist_users', 10, 2 );
function foo_whitelist_users( $pending, $post ) {
$user_ids = array( 2, 5, 10, 200 );
if ( in_array( get_current_user_id(), $user_ids ) ) {
$pending = true;
}
return $pending;
}
Thread Starter
joeco
(@joeco)
ahhh, perfect!
Thank you very much! I’ll report back after I know it works and close the ticket then.
I really appreciate your support!
I just realised the $pending should be false in that last example, so:
// Allow all posts by users by id
add_filter( 'bbp_modtools_moderate_post', 'foo_whitelist_users', 10, 2 );
function foo_whitelist_users( $pending, $post ) {
$user_ids = array( 2, 5, 10, 200 );
if ( in_array( get_current_user_id(), $user_ids ) ) {
$pending = false;
}
return $pending;
}
Thread Starter
joeco
(@joeco)
Hello Digital Arm,
Issue resolved. Please close the ticket.
Thank you very much for your help and patience!
Cheers!
It would be much better if this could be set within the admin. My site uses a lot of technical jargon that doesn’t always sound like English and a disproportionate number of posts are flagged for moderation. I’d much rather be able to just set and forget a user to the whitelist than having to trace through hundreds of users to identify their ID number then hand code it into the site.