jreviews:permission:listing.claim
Filters whether a user has permission to claim a listing.
Start here
Copy the boilerplate below, then add the logic you need. Return the modified first argument. New to hooks? Read the hooks primer first.
Fires when checking if user can submit a claim request for a listing
Parameters
| Name | Type | Description |
|---|---|---|
$canClaim |
bool |
Whether the user can claim the listing |
$user |
\JReviews\App\Models\User |
The user attempting to claim |
$listing |
\JReviews\App\Models\Listing |
The listing |
Boilerplate
Paste this into your hook file, then add your logic and return the modified first argument.
fwd_add_filter('jreviews:permission:listing.claim', function($canClaim, $user, $listing)
{
// Your code here
return $canClaim;
}, 20, 3);
Why the final numbers matter:
, 20, N sets the priority and how many arguments your callback accepts. If you use both $filterResult and $listing, keep , 20, 2 so both are passed to your callback.
Examples
Hide Claims Button from Guests
Prevent guest users from seeing or accessing the claim listing feature.
fwd_add_filter('jreviews:permission:listing.claim', function($canClaim, $user, $listing)
{
if ($user->isGuest()) {
return false;
}
return $canClaim;
}, 20, 3);
Source Files
app/Policies/ListingPolicy.php