JReviews logo Docs
Menu
Version

jreviews:listing:actions.{:name}

Filters the action buttons/blocks for a specific display context (detail, list, or card view).

Filter
Listing Detail
Since 6.0.0
Dynamic Hook

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.

Replace {:name} with the display context you want to target. See available contexts below.

Use jreviews:listing:actions when the same change should apply everywhere. It runs before the context-specific hooks.

Fires after the generic actions hook, allows context-specific customization

Action options

The filter result controls the action blocks that the listing page already provides. Favorite and Inquiry are built in, so you only need a hook when you want to restrict, reorder, or add actions. Keep the surrounding page values unless you are intentionally changing that page’s button layout.

blocks
manage, write_comment, compare, upload, favorite, claim, or inquire The available action keys. A block can be a callback-and-position array (recommended), a callable, or an HTML-safe rendered component/view; the latter two render at position 999. Ordinary strings are escaped, so do not use a raw HTML string for an action.
include
null by default, or an array of action keys null keeps all available actions. An array shows only the named actions.
exclude
[] by default, or an array of action keys Hides the named actions when include is null.
size
md by default; sm, md, or lg Controls the action button size.
variant
default by default; default or compact compact hides the favorite action label; default shows the regular action layout.

Parameters

Name Type Description
$filterResult array Same structure as jreviews:listing:actions
$listing \JReviews\App\Models\Listing The listing being displayed

Variations

Use one of these hook names when you only want to change a specific display context.

jreviews:listing:actions.detail
Fires in listing detail view
jreviews:listing:actions.detail_comments
Fires in listing detail comments view
jreviews:listing:actions.listings_list
Fires in listing list pages

For example, to target jreviews:listing:actions.detail only:

fwd_add_filter('jreviews:listing:actions.jreviews:listing:actions.detail', function($filterResult, $listing)
{
    // Your code here
    
    return $filterResult;
}, 20, 2);

Boilerplate

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

fwd_add_filter('jreviews:listing:actions.{:name}', function($filterResult, $listing)
{
    // Your code here
    
    return $filterResult;
}, 20, 2);
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

Enable Favorite and Inquiry on listing list pages

Favorite and Inquiry are built-in V6 action blocks. This keeps them available when a listing-list context has explicitly limited the displayed actions.

fwd_add_filter('jreviews:listing:actions.listings_list', function (array $filterResult, $listing): array {
    // A null include value already displays every available action.
    if ($filterResult['include'] === null) {
        return $filterResult;
    }

    $filterResult['include'] = array_values(array_unique([
        ...$filterResult['include'],
        'favorite',
        'inquire',
    ]));

    return $filterResult;
}, 20, 2);

Remove the built-in Inquiry action unless the listing is featured.

fwd_add_filter('jreviews:listing:actions', function (array $filterResult, $listing): array {
    if ($listing->featured) {
        return $filterResult;
    }

    $blocks = fwd_collect($filterResult['blocks'] ?? []);
    $blocks->forget('inquire');
    $filterResult['blocks'] = $blocks;

    return $filterResult;
}, 20, 2);

Hide Write Review for guests

Remove the built-in Write Review action for visitors who are not signed in.

fwd_add_filter('jreviews:listing:actions', function (array $filterResult, $listing): array {
    if (! fwd_auth()->user()->isGuest()) {
        return $filterResult;
    }

    $blocks = fwd_collect($filterResult['blocks'] ?? []);
    $blocks->forget('write_comment');
    $filterResult['blocks'] = $blocks;

    return $filterResult;
}, 20, 2);

Add a Visit Website action from a custom field

Add an external website action only when the website custom field contains a valid HTTP or HTTPS URL.

fwd_add_filter('jreviews:listing:actions', function (array $filterResult, $listing): array {
    // Replace jr_website with your Website custom field name.
    $url = trim((string) $listing->getFieldValue('jr_website', ''));
    $scheme = strtolower((string) parse_url($url, PHP_URL_SCHEME));

    if ($url === '' || ! filter_var($url, FILTER_VALIDATE_URL) || ! in_array($scheme, ['http', 'https'], true)) {
        return $filterResult;
    }

    $filterResult['blocks'] = fwd_collect($filterResult['blocks'] ?? [])
        ->put('visit-website', [
            'callback' => fn () => \JReviews\App\View\Components\Blocks\Button::make()
                ->label('Visit website')
                ->iconName('outline.globe-alt')
                ->link($url)
                ->asLink()
                ->color('secondary')
                ->size($filterResult['size'])
                ->withAttributes([
                    'data-jr-action' => 'visit-website',
                    'target' => '_blank',
                    'rel' => 'noopener noreferrer',
                ])
                ->render(),
            'position' => 75,
        ]);

    return $filterResult;
}, 20, 2);

Add an EasySocial message action

Joomla only. Add EasySocial's message trigger as a JReviews action button for signed-in users.

fwd_add_filter('jreviews:listing:actions', function (array $filterResult, $listing): array {
    if (! class_exists('ES') || fwd_auth()->user()->isGuest() || ! $listing->user?->id) {
        return $filterResult;
    }

    $filterResult['blocks'] = fwd_collect($filterResult['blocks'] ?? [])
        ->put('easysocial-message', [
            'callback' => fn () => \JReviews\App\View\Components\Blocks\Button::make()
                ->label('Contact member')
                ->iconName('outline.chat-bubble-left-right')
                ->color('secondary')
                ->size($filterResult['size'])
                ->withAttributes([
                    'data-jr-action' => 'easysocial-message',
                    'data-es-conversations-compose' => true,
                    'data-es-conversations-id' => $listing->user->id,
                ])
                ->render(),
            'position' => 75,
        ]);

    return $filterResult;
}, 20, 2);

Add a BuddyPress or BuddyBoss message action

WordPress only. Add a link to BuddyPress or BuddyBoss's compose-message page for signed-in users.

fwd_add_filter('jreviews:listing:actions', function (array $filterResult, $listing): array {
    if (! function_exists('bp_loggedin_user_domain') || fwd_auth()->user()->isGuest() || ! $listing->user?->id) {
        return $filterResult;
    }

    $recipient = bp_core_get_username($listing->user->id);

    if (! $recipient) {
        return $filterResult;
    }

    $url = wp_nonce_url(bp_loggedin_user_domain().bp_get_messages_slug().'/compose/?r='.$recipient);

    $filterResult['blocks'] = fwd_collect($filterResult['blocks'] ?? [])
        ->put('buddypress-message', [
            'callback' => fn () => \JReviews\App\View\Components\Blocks\Button::make()
                ->label('Send message')
                ->iconName('outline.chat-bubble-left-right')
                ->link($url)
                ->asLink()
                ->color('secondary')
                ->size($filterResult['size'])
                ->withAttributes(['data-jr-action' => 'buddypress-message'])
                ->render(),
            'position' => 75,
        ]);

    return $filterResult;
}, 20, 2);

Add an action with a callable

Use a callable when the action can render after the built-in actions. Callables use the default position 999.

fwd_add_filter('jreviews:listing:actions', function (array $filterResult, $listing): array {
    $filterResult['blocks'] = fwd_collect($filterResult['blocks'] ?? [])
        ->put('help', function () {
            return \JReviews\App\View\Components\Blocks\Button::make()
                ->label('Help')
                ->link('/help')
                ->asLink()
                ->color('secondary')
                ->render();
        });

    return $filterResult;
}, 20, 2);

Add an action as a rendered component

A rendered JReviews component or view is accepted directly and uses the default position 999. Do not use a raw HTML string for an action.

fwd_add_filter('jreviews:listing:actions', function (array $filterResult, $listing): array {
    $helpAction = \JReviews\App\View\Components\Blocks\Button::make()
        ->label('Help')
        ->link('/help')
        ->asLink()
        ->color('secondary')
        ->render();

    $filterResult['blocks'] = fwd_collect($filterResult['blocks'] ?? [])
        ->put('help', $helpAction);

    return $filterResult;
}, 20, 2);
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

  • resources/views/site/components/listing/actions.blade.php