I have been having help from a web developer as currently if a vendor just registers and does not add a listing, they are able to send messages to other vendors, without other vendors to be able to see the profile of this vendor.
So he applied this php code and with this if a vendor who has registered and contacts other vendor or replies to a listing he is restricted from sending message and gets a message that he needs a listing to send a message. This is how it should work. With the code below it works but next day it reverts back to default, and vendor with no listing are then able to send messages.
Any thoughts why this is reverting. We have gone a long way in getting the site up and running but now it seems to have come a big problem like this. You help will be very much appreciated at this sticky point please. Will be verso grateful. The code is
add_filter(
'hivepress/v1/forms/message_send/errors',
function($errors, $form){
$values = $form->get_values();
if(!$values){
return $errors;
}
$user_id = hivepress()->helper->get_array_value($values, 'recipient');
if(!$user_id){
return $errors;
}
$vendor_id = \HivePress\Models\Vendor::query()->filter(['user' => $user_id])->get_first_id();
if(!$vendor_id){
return $errors;
}
$listing_count = \HivePress\Models\Listing::query()->filter(['vendor' => $vendor_id])->get_count();
if($listing_count > 0){
return $errors;
}
$errors[] = 'Unable to send message to vendor with no listings.';
return $errors;
},
1000,
2
);