Signature
apply_filters( 'mam_gd_get_event_schedule', array $schedules, int $event_id );
| Parameter | Type | Description |
|---|---|---|
$schedules |
array | Pass-through default — usually an empty array. |
$event_id |
int | The GeoDirectory event post ID to look up. |
Returns: array — upcoming schedules for the event, as returned by GeoDir_Event_Schedules::get_schedules($event_id, 'upcoming').
Purpose
A producer-pattern filter: this plugin registers a handler for it but does not itself call apply_filters. External code (or other MAM plugins) should call apply_filters('mam_gd_get_event_schedule', [], $event_id) to read upcoming schedules for a GD event without having to deal with GeoDir_Event_Schedules directly.
The handler is a thin shim:
public function mam_gd_get_event_schedule( $schedules, $event_id ) {
if ( class_exists( 'GeoDir_Event_Schedules' ) ) {
$schedules = GeoDir_Event_Schedules::get_schedules( $event_id, 'upcoming' );
}
return $schedules;
}
When the GeoDir Event Manager plugin is not active, the filter returns the input unchanged.
When it runs
Once per apply_filters call. The plugin registers the handler at priority 10, so external callers can layer their own at higher or lower priorities to override the result.
Examples
Read upcoming schedules
$schedules = apply_filters( 'mam_gd_get_event_schedule', [], $event_id );
foreach ( $schedules as $schedule ) {
// Each $schedule is a GeoDir_Event_Schedule object with start_date, end_date, etc.
}
Replace with a custom schedule resolver
add_filter( 'mam_gd_get_event_schedule', 'my_app_custom_schedules', 20, 2 );
function my_app_custom_schedules( $schedules, $event_id ) {
// Use a custom data source (e.g., an external calendar API)
return my_external_api_get_schedules( $event_id );
}
A higher priority (20 here) ensures your callback runs after the built-in handler and overrides its result.
Gotchas
- No-op when GeoDir Event Manager is missing. The built-in handler short-circuits if
GeoDir_Event_Schedulesdoesn’t exist. Your callback should also handle that case, or you’ll get fatal errors when the plugin is not loaded. - Schedule shape.
GeoDir_Event_Schedules::get_schedulesreturns an array ofstdClass-like objects withstart_date,end_date,start_time,end_time. Don’t depend on additional properties. 'upcoming'is hard-coded. This filter does not let you ask for past or all schedules. For broader queries, callGeoDir_Event_Schedules::get_schedulesdirectly with a different flag.
Verification
This article was last verified against:
- Plugin:
mam-geodirectoryv2.1.5 - Plugin: GeoDir Event Manager (
GeoDir_Event_Schedules) - Source:
mam-geodirectory.php—mam_gd_get_event_schedule()
Re-verify whenever the handler’s flag ('upcoming') changes, the GeoDir Event Manager schedule API renames get_schedules, or the registration priority moves.
Related articles
- Plugin: mam-geodirectory
- Listing detail content sections
- Hook: mam_geodirectory_event_card
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 |
