Hook: mam_geodirectory_skip_record

Signature

apply_filters( 'mam_geodirectory_skip_record', bool $skip, int $listing_id );
Parameter Type Description
$skip bool Default false — keep the listing.
$listing_id int The ID of the listing under consideration.

Returns: bool — true to drop the listing; false to keep it. You must return a boolean.


Purpose

Drops a single listing from the response before any per-listing finalisers run. Useful when:

  • You have a soft-deletion scheme (a custom is_hidden post meta) and need to honor it.
  • You want to A/B test which listings appear in the app.
  • You want to hide listings authored by users who failed an identity check.

This filter runs after the built-in visibility checks (status, category, authorship), so you can rely on the basic sanitisation having already happened. $skip = true short-circuits everything else for that listing.


When it runs

Inside should_include_listing():

if ( apply_filters( 'mam_geodirectory_skip_record', false, $listing['id'] ) ) {
    return false;
}
return true;

This is the last check in should_include_listing, called from the per-listing loop in get_data_for_app() for every row. The filter fires once per listing per request — for a directory of 5,000 listings, that’s 5,000 calls. Keep your callback fast.


Examples

Hide listings flagged in a custom meta key

add_filter( 'mam_geodirectory_skip_record', 'my_app_hide_flagged_listings', 10, 2 );

function my_app_hide_flagged_listings( $skip, $listing_id ) {
    if ( get_post_meta( $listing_id, 'my_app_hidden', true ) === 'yes' ) {
        return true;
    }
    return $skip;
}

Hide listings owned by a banned-users role

add_filter( 'mam_geodirectory_skip_record', 'my_app_hide_banned_authors', 10, 2 );

function my_app_hide_banned_authors( $skip, $listing_id ) {
    static $cache = [];
    $author_id = (int) get_post_field( 'post_author', $listing_id );
    if ( ! isset( $cache[ $author_id ] ) ) {
        $user = get_userdata( $author_id );
        $cache[ $author_id ] = $user && in_array( 'banned', $user->roles, true );
    }
    return $cache[ $author_id ] ? true : $skip;
}

Gotchas

  • Per-listing fire rate. A directory of N listings runs this filter N times per request. Caching expensive lookups inside the callback (e.g., the static $cache pattern above) is essential at scale.
  • Runs before finalisers. You don’t have access to the marker, image, or category data yet — only the raw listing row from the GD detail table. If your decision needs derived data, use Hook: mam_geodirectory_final_listings instead.
  • Always return a boolean. Returning a string or array silently coerces and may produce surprising results.
  • Visible to admin-approval mode. When admin-approval mode is active, should_include_listing short-circuits to true before this filter runs. So your callback does not affect the admin approval queue.
  • Doesn’t bypass the cache. The plugin’s per-request cache (when enabled) skips the per-listing finalisers but still runs should_include_listing — your filter fires either way.

Verification

This article was last verified against:

  • Plugin: mam-geodirectory v2.1.5
  • Source: content-classes/local-app-geodirectory-v2-class.phpshould_include_listing()

Re-verify whenever the visibility-check pipeline in should_include_listing is reordered or admin-approval mode’s short-circuit is moved.


  • Plugin: mam-geodirectory
  • Hook: mam_geodirectory_final_listings
  • Hook: mam_geodirectory_explcit_listings
  • Mobile listing data shape

Metadata

Field Value
Article type Hook Reference
Plugin slug mam-geodirectory
Applies to plugin version 2.1.5+
Category Extending MAM Suite
Hook type filter
Audience PHP developer
Last verified 2026-05-01
Contents

    Need Support?

    Can’t find the answer you’re looking for? Don’t worry we’re here to help!