Require users to create at least 1 listing

Hello, I want to implement a requirement where users must create at least one listing before they can reply to other listings. This applies only to logged-in users. If they attempt to reply without meeting this requirement, a popup will appear informing them, along with a button directing them to the create listing page

Hi,

You can try this code snippet, it doesn’t allow sending messages (by showing errors in the message form) until at least 1 listing is added by user:

add_filter('hivepress/v1/forms/message_send/errors', function ($errors) {

 $listing_count = \Hivepress\Models\Listing::query()->filter(
  [
   'status' => ['draft', 'publish'],
   'user'       => get_current_user_id(),
  ]
 )->get_count();

 if ($listing_count < 1) {
  $errors [] = 'You must create at least one listing before you can reply to other listings.';
    }
 return $errors;
}, 1000);

Creating a custom modal is possible, but requires further customizations.