Posted: November 27, 2018 at 5:30 am
|
Is there a way to add options to the bulk actions drop-down in the event listing of the admin area? I have a function that will update all the waitlist settings if I pass in an array of event ids, and I’d like to be able to call it from the bulk actions drop-down. It would also be handy for bulk updates of regsitration start dates and end dates, etc. If we can hook in to add an option to the drop-down, what is the best way to show a few fields to enter the values desired for the given update? A pop-up window? Or can the bulk update have a multi-step process of screens? |
|
I tried the steps in this (https://wpengineer.com/2803/create-your-own-bulk-actions/), but it only shows my new bulk action on the list of Posts, not on my Events list. I’m guessing there’s a special filter for custom post types? Or I need to change the edit-posts screen ID to whatever one is relevant for events? |
Yes, you can. The bulk dropdown options are unique for each ‘view’, the views are the links along the top of the table, ‘View all events’, ‘draft’, ‘trash’ and so on. As the options relate to each view, they are also set on each of those views and they are passed through a filter to allow you to change them:
For your request that’s going to be That is passed an array of arrays, each array is the view with the options for that view, for example, the default view is ‘all’ and that looks like:
So you can add options to the ‘bulk_action’ array using the above filter, however, each of those is also a route within the admin so you’ll also nee dot register your custom route if you do it this way. As you have the EE4 Everything license I recommend taking a look at one of our add-ons for an example of how to add a page route, the EE4 Attendee mover add-on has an example (search for ‘attendee_mover_page_routes’). The filter you would use is likely
How so? Note that the dates within EE events are stored on the datetimes/tickets, so your going to need to update those rather than the event itself. ‘Registration start dates’ is a term from EE3 but I’m assuming this is aimed at EE4.
The bulk option basically just calls a function so you can do any of the above if you prefer, but its not something we have an examples/snippets of. |
|
|
I looked at the attendee mover routes and I am a bit confused about it. I see the line: add_filter( 'FHEE__Extend_Registrations_Admin_Page__page_setup__page_routes', array('EED_Attendee_Mover', 'attendee_mover_page_routes'), 10, 2 ); and I understand that, ‘attendee_mover_page_routes’ is the name of the callback function, but what must the first element of that array be? In this case, it matches the name of the class, but I’m not creating a new class, just adding the hooks into a custom plugin. So I tried adding this to my custom plugin: add_filter('FHEE__Extend_Events_Admin_Page__page_setup__page_routes', array('Compass Mods', 'compass_ee_page_routes'), 10, 2); // callback for FHEE__Extend_Events_Admin_Page__page_setup__page_routes function compass_ee_page_routes(array $page_routes, Events_Admin_Page $admin_page) { $req_data = $admin_page->get_request_data(); $EVT_ID = ! empty($req_data['EVT_ID']) && ! is_array($req_data['EVT_ID']) ? $req_data['EVT_ID'] : 0; $page_routes['create_waitlist'] = array( 'func' => array('Compass Mods', 'my_bulk_action_handler'), 'EVT_ID' => $EVT_ID, ); return $page_routes; } But adding that code makes the following error appear on the Events Admin List page: An EE_Error exception was thrown! code: EE_Admin_Page - _verify_routes - 816 "No page routes have been set for the Events admin page. Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly." I did get the Create Waitlists option to show in the bulk dropdown using add_filter( 'bulk_actions-toplevel_page_espresso_events', 'register_compass_bulk_actions' ); function register_compass_bulk_actions($bulk_actions) { $bulk_actions['create_waitlist'] = __( 'Create Waitlist', 'create_waitlist'); return $bulk_actions; } But when I tried to submit the form so it would call my bulk action handler function, I got an EE exception about the page routes, too. Help?
Yes, I am in the process of upgrading from EE3 to EE4, sorry about the confusion with wording. We only have one ticket per event, so I would like a bulk action that updates the start or end dates for all tickets for all events. Since we have 100s of classes offered each quarter, if we decide to change our registration day, it is a pain to have to manually edit each one, hence the need for a bulk action. |
If you’re not creating a new class, then you just pass in the function name, like this:
Similarly, in your
|
|
You’ll find more examples for using add_filter() in these WordPress developer resources: https://developer.wordpress.org/reference/functions/add_filter/ |
|
The support post ‘bulk action hook for admin event list page?’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.