Skip to content

Instantly share code, notes, and snippets.

@hivepress
Created February 20, 2023 20:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hivepress/7fe7d92419dd4f05e99165385cfb660d to your computer and use it in GitHub Desktop.
Save hivepress/7fe7d92419dd4f05e99165385cfb660d to your computer and use it in GitHub Desktop.
Restrict making offers to vendors with at least 1 listing #hivepress #requests
<?php
add_filter(
'hivepress/v1/forms/offer_make/errors',
function( $errors ) {
$listing_id = \HivePress\Models\Listing::query()->filter(
[
'status' => 'publish',
'user' => get_current_user_id(),
]
)->get_first_id();
if ( ! $listing_id ) {
$errors[] = 'error text here';
}
return $errors;
},
1000
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment