Services plugin: Service Date and Time is used to move service from "upcoming" to "past"
Hi,
Once the service date / time has passed, the service is moved from Upcoming (and Next) to the Past. This is very useful functionality.
It's a bit of a surprise that this happens immediately at the start of the service.
With COVID-19 sequestration forcing online service streaming, folks don't need to check very much ahead of time for the service details.
At the moment, if they check the website an instant after the Service Start Time, they won't see the link, because today's service will have moved into the past.
I'm aware that we can address this by changing the Service Start Time to be the moment when WE want the service to be moved to the past. This is acceptable, but if we use it for that purpose, then other administrators are likely to be confused.
I wonder if the label of that field could be changed to be more reflective of how the value is used.
Another option would be to have a setting for how long after the start of the service it should appear as an upcoming / next service. For our purposes (uusanmateo.org), we'd probably set this to 90 minutes, because our services are generally over at about 60-75 minutes.
This might be something settable at the plugin level, so that it wouldn't need to be set for each service.
Thanks,
Dave
Comments (5)
The dates on Services pages are documented here: https://www.uua.org/communications/websites/wordpress-theme/documentati…
How about using the ending time for the "Service Date and Time" field? That ought to delay when the next service appears.
We lost some replies to this post, so I'm going to post them.
Charles McNulty said this six months ago:
Also looking forward to this - if any of you are technically inclined, I've fixed this for our site with the following line change: uua-services/includes/widgets/class-uua-widget-featured-service.php
'value' => (current_time('timestamp') - (60*60)),
subtracting 60*60 will leave the "current service" up for an hour past start of service - if you'd like to extend it through coffee hour you could do (60*60*2) for instance.
Kevin Vess replied three months ago:
First, I hope you applied your change using the uua_widget_featured_service_query_args filter, otherwise your changes will be lost the next time you update the UUA Services plugin.
Second, to make the code more human readable, I recommend using the builtin Time Constants. For example:
'value' => ( current_time('timestamp') - ( HOUR_IN_SECONDS ) ),
OR
'value' => ( current_time('timestamp') - ( 2 * HOUR_IN_SECONDS ) ),
Thanks!
Charles replied:
Thanks Kevin, ahhhh.. yeah, that's... definitely what I did. But just in case anyone thought that maybe I didn't do that, here's some updated code that definitely does do that now:
function jruuc_keep_service_live($query_args){
if(isset($query_args['meta_query'])) {
$meta_key = $query_args['meta_key'];
// don't know why this would have more than one key, but let's not make assumptions
$index = array_search($meta_key, array_column($query_args['meta_query'], 'key'), true);
if (isset($query_args['meta_query'][$index]['value'])) {
// finally, adjust the query to be two hours in the past, so that it will keep the "active" one for two hours longer
$query_args['meta_query'][$index]['value'] = current_time('timestamp') - (2 * HOUR_IN_SECONDS);
}
}
return $query_args;
}
// add filter to adjust hours
add_filter( 'uua_widget_featured_service_query_args', 'jruuc_keep_service_live');
So Kevin replied:
Haha! I always knew you hooked into the filter properly ;)
Thanks for the excellent code example on how to extend the active service in the Featured Upcoming Service widget!
Also, if you use the Upcoming Service widget in the sidebar of other pages and want to apply this change to those widgets as well, simply add another filter hook with your same function:
// add filter to adjust hours
add_filter( 'uua_widget_featured_service_query_args', 'jruuc_keep_service_live' );
add_filter( 'uua_widget_upcoming_services_query_args', 'jruuc_keep_service_live' );
Is it possible for folks to contribute to the code for the plugin? We have several requirements that aren't satisfied, and I'd much rather contribute to the fix, than only to the problem statements.
We welcome everyones feedback and suggestions to help make the UUA Theme and Services plugin the best possible.
You can post feature requests through the forum or submit code for review and implementation by emailing outreach@uua.org, but the code repository is only accessible by the team maintaining it. The code is not publicly available to allow others to submit pull requests at this time.