JReviews logo Docs
Menu
Version

jreviews:custom_field.output:{:name}

Field-specific filter that fires for individual custom fields after the generic filter. Allows modifying output, hiding fields, or customizing display for specific fields. Returning false or null hides the field.

Filter
Custom Fields
Since 6.0.0
Generic Version Available
This hook has a generic version jreviews:custom_field.output that fires for all variations. Both hooks receive the same parameters. The generic version fires before the specific variation hooks, allowing you to apply logic across all variations or target specific ones.

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

Fires during field output rendering for both listing and comment fields, after the generic filter

Parameters

Name Type Description
$output \FWD\Illuminate\Support\Collection|null Collection of Fluent objects with 'text', 'value', and 'output' properties. Can be null if no output.
$this->field
$this->object
$this
$field \JReviews\App\Models\Field The custom field model instance
$object \JReviews\App\Models\Listing|\JReviews\App\Models\Comment The listing or comment object that contains this field
$fieldType \JReviews\App\Helpers\FieldTypes\BaseFieldType The field type helper instance

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:

jr_cuisine
jr_location
jr_notes

For example, to target the jr_cuisine variation, you would use:

fwd_add_filter('jreviews:custom_field.output:jr_cuisine', function($output, $this->field, $this->object, $this, $field, $object, $fieldType)
{
    // Your code here
    
    return $output;
});

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:custom_field.output:{:name}', function($output, $this->field, $this->object, $this, $field, $object, $fieldType)
{
    // Your code here
    
    return $output;
});
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

Show field output only to listing owner and admins

Restrict visibility of a private notes field to only the listing owner and site administrators by returning false for other users.

fwd_add_filter('jreviews:custom_field.output:jr_notes', function($output, $field, $object, $fieldType) {
    $user = fwd_auth()->user();
    
    if ($user->isAdmin() || $user->id === $object->owner_id) {
        return $output;
    }
    
    return false;
});

Re-order output of multi-select fields alphabetically

When using the auto-complete UI for multiple select lists, the options are stored in the order in which they are selected. And a user can also re-order them by dragging and dropping the tags in the desired order. The following code will override the order of a specific field, jr_cuisine, and re-order the display options alphabetically.

fwd_add_filter('jreviews:custom_field.output:jr_cuisine', function($output, $field, $object, $fieldType) {
    return $output->sortBy('text');
});

Source Files

  • app/Helpers/FieldTypes/BaseFieldType.php