I tried the first 2 codes and not the third one. But I saw that even though I had no listing but only registered, I was still able to communicate with other listongs by clicking button reply to message.
I want that unless I have a listing I should not be allowed to communicate.
If I am using code snippet plugin do I still need the child theme?
Thanks
I haven’t tried this code yet, but I looked it up and it does the opposite of what you want to achieve. This check the recipient and not the sender of the message, so I modified the snippet and now it checks the sender of the message. It is important to note that, this will only work if the message sender is a vendor and not a user.
/* Check if the sender of the message has a listing, and prevent it from being sent if they don't.
*/
add_filter(
'hivepress/v1/forms/message_send/errors',
function($errors, $form){
$values = $form->get_values();
if(!$values){
return $errors;
}
// Get the current user ID
$current_user_id = get_current_user_id();
if(!$current_user_id){
return $errors;
}
// Get the vendor ID associated with the current user
$vendor_id = \HivePress\Models\Vendor::query()->filter(['user' => $current_user_id])->get_first_id();
if(!$vendor_id){
return $errors;
}
// Get the listing count for the current vendor
$listing_count = \HivePress\Models\Listing::query()->filter(['vendor' => $vendor_id])->get_count();
// If the current user (vendor) has no listings, add an error
if($listing_count == 0){
$errors[] = 'Unable to send message. You must have at least one active listing to send messages.';
}
return $errors;
},
1000,
2
);
Your second question: I don’t use snippet inserter, because I think it’s unnecessary thing, so I can’t answer for that, but if you add customizations to your main theme, you will losing all of that customizations when you update the main theme.
In some profile pages the related listing show at the bottom but in some profile pages it will not show related listed.
For 2 categories created BOYS and GIRLS, how does it know that on Girls listings it has to show only girls in the related listing and not boys and same for boys? What else could be the problem? Most of the things we have sorted, I think reading the forum related listing is linked to categories and Geolocation. Can it be set to categories only? If so then it be useful becos, all Girls category can be then shown as related listings, rather than 2 profiles both from London (example) become related listing. I tried in Hivepress > Settings > Geolocation adding Vendor or Listing one at a time, but then it removes the map from front end, leaving both on, makes relating listing to not show properly. Help help help !! please. As I have some webdeveloper who has now helped me with other issues so if you can may be give some code to overwrite this or advice for the developer then I can pass your helpful comments to him which will speed up the process. Thanks
Or even if I can show all profiles of one category in related listings then that will also work for me like on GIrl profile page if somehow I can show all Girl categories profiles and similarly on Boy Profile page if i can show all boys profiles in related listings then it wil also work out. How can I achieve this. I have only 2 categories, still like ot keep the geolocation map
Thanks