Posted on by

Creating Your Own “With Selected” Actions in the PDB Admin

Participants Database has a simple kind of mass-edit functionality in the backend List Participants page. If one or more records are selected in the list, a function can be performed on all of them. Normally, this is things like deleting records or setting the “approved” flag. Other Participants Database add-ons add their own functions to the possibilities there.

It is possible, for those with some coding skills, to write your own custom function that can be performed on selected records in the admin listing. This is all done using filters and actions, no modification of the plugin files is needed.

These are the two filters and one action you will need to use:
pdb-admin_list_with_selected_actions – passes in an array of action selections; you would add your custom one to this.
pdb-admin_list_with_selected_action_conf_messages – adds a confirmation message for your function.
pdb_admin_list_with_selected/{$action} – passes in an array of selected ids. This is where you would perform whatever operation you need for your function.

A Simple Example

For the purposes of this tutorial, we’ll set up a simple function that can be performed on a number of records. In our example, we want to be able to set the selected records to a status of “paid.” We have a field named ‘payment_status’ which could have one of several values, but we want to be able to select a bunch of records and mark them as paid.

Take a look at this commented code, it should be clear how to set up whatever function you have in mind. This file works as a plugin, you can download it and install it on your site if you want.

Leave a Reply
You have to agree to the comment policy.

Leave a Reply
You have to agree to the comment policy.