Points needed to initiate a new message setting has no effect
Plugin: Fluent Messaging
Summary:
The "Points needed to initiate a new message" threshold setting does not block users when "Who can initiate message" is set to "Everyone." Users with points below the threshold can still initiate new message threads.
Steps to Reproduce:
- Go to FluentCommunity > Features & Addons > Messaging Settings
- Set "Who can initiate message" to "Everyone"
- Set "Points needed to initiate a new message" to 30
- Save settings
- Log in as a user with fewer than 30 total points
- Initiate a new direct message to another user
Expected: User is blocked from initiating the message.
Actual: Message sends successfully. No restriction is applied.
Root Cause:
In ChatHelper::canInitiateMessage() (ChatHelper.php ~line 245):
$canInitiateMessage = $messagingConfig['who_can_initiate_message'] === 'everyone' || $isMod;
if (!$isMod && $messagingConfig['points_to_initiate_message'] > 0) {
// ...
if ($points > (int)$messagingConfig['points_to_initiate_message']) {
$canInitiateMessage = true;
}
}
When set to "everyone," $canInitiateMessage is already true on line 257. The points check (lines 259-264) only sets $canInitiateMessage = true β it never sets it to false. So the threshold cannot block anyone when messaging is open to everyone.
Suggested Fix:
$canInitiateMessage = $messagingConfig['who_can_initiate_message'] === 'everyone' || $isMod;
if (!$isMod && $messagingConfig['points_to_initiate_message'] > 0) {
$xProfile = $user->xprofile;
$points = $xProfile ? (int)$xProfile->total_points : 0;
if ($points <= (int)$messagingConfig['points_to_initiate_message']) {
$canInitiateMessage = false;
}
}
Environment:
- FluentCommunity Pro Version 2.2.05
- Fluent Messaging Version 2.2.05
- WordPress 6.9
- PHP 8.1
Ahh! I see that now. Will fix that in the next version. Thanks for reporting.
Shahjahan JewelΒ I got your back π