Events Manager plugin
One of the most used plugins for managing events on a WordPress is the Events Manager.
It is a very easy to use and highly configurable plugin, surprisingly it lacks a feature allowing an admin to search bookings.
The goal
One of our clients asked for a solution because they lost too much time, manually sifting through bookings.
The first thing to do in such a case is check wether or not someone else already requested the feature, or if it got added along the way but needs to be configured.
Unfortunately other people had already requested it, but the feature was never built.
As a consequence, we had to build a custom WordPress plugin to extend the features of Events Manager.
The solution
We looked at the database and source code of the Events Manager plugin.
It was immediately obvious that all (custom) booking data such as name, email, etc. was serialised and stored in a single column.
All we had to do was create an admin page that makes use of the following search function, displays the results, wrap it in a WordPress plugin and done.
function as_em_search( $search_term ) {
global $wpdb;
$table_name = EM_BOOKINGS_TABLE;
$query = $wpdb->prepare(
"SELECT booking_id, event_id, booking_spaces, booking_meta
FROM $table_name
WHERE booking_meta LIKE %s ORDER BY event_id",
'%' . $search_term . '%'
);
return $wpdb->get_results($query) ;
}
Spreading the joy
To have more people benefit from this simple but handy plugin, we put it up on github under a MIT license.
Installation instructions can be found in the README.md.