jreviews:permission:listing.update_listing_media
Filters whether a user has permission to update/edit media for an existing listing. Return false to deny permission.
You need to have a working knowledge of Hooks before you get started.
Fires when checking media edit permissions, before the media management page is displayed or changes are saved
Parameters
| Name | Type | Description |
|---|---|---|
$canUpdateMedia |
bool |
Whether the user can update the listing media based on media access settings |
$user |
\JReviews\App\Models\User |
The user attempting to update the media |
$listing |
\JReviews\App\Models\Listing |
The listing whose media is being updated |
Boilerplate Code
Use the boilerplate code to start using the filter, and add your own logic to modify the first argument and return it.
fwd_add_filter('jreviews:permission:listing.update_listing_media', function($canUpdateMedia, $user, $listing)
{
// Your code here
return $canUpdateMedia;
});
Examples
Re-map the listing media update permission to the listing update permission
Media update permissions can be set globally, but not at the listing type level. In this case, if you need more fine-grained control and your listing updates permissions generally match what you also want for the media update permissions, then you can map one to the other.
fwd_add_filter('jreviews:permission:listing.update_listing_media', function($canUpdateMedia, $user, $listing) {
return $user->can('update', $listing);
}, 10, 3);
Source Files
app/Policies/ListingPolicy.php