JReviews logo Docs
Menu
Version

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.

Filter
Listing Permissions
Since 6.0.0

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 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

Paste this into your hook file, then add your logic and return the modified first argument.

fwd_add_filter('jreviews:permission:listing.update_listing_media', function($canUpdateMedia, $user, $listing)
{
    // Your code here
    
    return $canUpdateMedia;
}, 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

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);
}, 20, 3);
Development & Support
Hooks are for custom development and are not included with support. Use the examples as a starting point and test changes on a staging site first.

Source Files

  • app/Policies/ListingPolicy.php