JReviews logo Docs
Menu
Version

jreviews:listing_form.custom_fields:{:name}

Filters the collection of custom fields displayed in the listing submission/edit form, allowing add-ons to show or hide specific fields based on custom logic (e.g., pricing plans, user roles, listing state).

Filter
Custom Fields
Since 6.0.0

You need to have a working knowledge of Hooks before you get started.

Fires when building listing form, after permission-based field filtering, before per-field hooks

Parameters

Name Type Description
$param1
$field \JReviews\App\Models\Field The custom field model
$this->listing
$fields \FWD\Illuminate\Support\Collection Collection of Field models to be displayed
$listing \JReviews\App\Models\Listing The listing being created or edited
$show bool Whether to show the field (true) or hide it (false)

Variations

This dynamic hook fires for each of the following variations. The {:name} placeholder in the hook name is replaced with one of these values:

- `jreviews:listing_form.custom_fields:jr_city` - For field with name 'jr_city' - `jreviews:listing_form.custom_fields:jr_featured` - For field with name 'jr_featured' - Pattern follows field name exactly

For example, to target the - `jreviews:listing_form.custom_fields:jr_city` - For field with name 'jr_city' - `jreviews:listing_form.custom_fields:jr_featured` - For field with name 'jr_featured' - Pattern follows field name exactly variation, you would use:

fwd_add_filter('jreviews:listing_form.custom_fields:- `jreviews:listing_form.custom_fields:jr_city` - For field with name 'jr_city' - `jreviews:listing_form.custom_fields:jr_featured` - For field with name 'jr_featured' - Pattern follows field name exactly', function($param1, $field, $this->listing, $fields, $listing, $show)
{
    // Your code here
    
    return $param1;
});

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:listing_form.custom_fields:{:name}', function($param1, $field, $this->listing, $fields, $listing, $show)
{
    // Your code here
    
    return $param1;
});
Development & Support
Customizations are not included with support. We provide this information to make it easier for developers to extend the functionality. From time to time we may have some availability for custom work. Get in touch to see if there's an opportunity to work together.

Examples

Hide Specific Fields Based on Pricing Plan

Remove fields that are not included in the user's current pricing plan subscription.

fwd_add_filter('jreviews:listing_form.custom_fields', function($fields, $listing)
{
    // Example: Only show 'jr_featured' field to premium users
    $user = fwd_auth()->user();
    
    if (! $user->hasPremiumSubscription()) {
        $fields = $fields->reject(function($field) {
            return $field->name === 'jr_featured';
        });
    }
    
    return $fields;
});

Limit Fields for Guest Users

Show only basic fields to guest users during listing creation.

fwd_add_filter('jreviews:listing_form.custom_fields', function($fields, $listing)
{
    $user = fwd_auth()->user();
    
    if ($user->isGuest()) {
        // Only allow these basic fields for guests
        $allowedFields = ['jr_name', 'jr_email', 'jr_phone'];
        
        $fields = $fields->filter(function($field) use ($allowedFields) {
            return in_array($field->name, $allowedFields);
        });
    }
    
    return $fields;
});

Hide a Specific Field for Non-Premium Users

Hide the 'jr_featured' field for users without premium subscription.

fwd_add_filter('jreviews:listing_form.custom_fields:jr_featured', function($show, $field, $listing)
{
    $user = fwd_auth()->user();
    
    if (! $user->hasPremiumSubscription()) {
        return false;
    }
    
    return $show;
});

Source Files

  • app/Http/Site/Yoyo/Listing/AbstractForm.php