Reply To: Roles and Capabilities in bbPress 2.2
Hey 👋Â
Thank you @Robin-W,
In the meantime I got to know the WP-Cli-Cli package specific to WordPress, which does not work either (I opened an issue visible here).
To locate the context, I use WooCommerce Subscription plugin and I needed that when a subscription is canceled, access to the bbPress forum is blocked.
I leave here the snippet that I made and that does the job:
add_action('woocommerce_subscription_status_cancelled', 'block_forum_user_after_subscription_cancellation_s', 10, 1);
function block_forum_user_after_subscription_cancellation_s($subscription)
{
$user_id = $subscription->get_user_id();
$new_role = 'bbp_blocked';
bbp_set_user_role($user_id, $new_role);
}
(I also have a webhook version with the WordPress Rest API for remote use, if necessary contact me)