wp_lib_dash_action - roberts-sandbox/create-repo GitHub Wiki
###Description
This action hook allows developers to modify all Dash actions, requests from the Library Dashboard to modify the library in some way. Besides modifying existing Dash actions, this hook could be used to add multiple new Dash actions via a switch statement, similar to how WP-Librarian currently handles Dash actions. If you only want to add a single custom Dash action the more specific hook wp_lib_dash_action_ would be more appropriate.
###Context
To access the Library Dashboard users must be at the minimum a librarian and thus logged in as a WordPress user. No nonce validation has yet happened as nonces are specific to the Dash page they came from.
###Parameters
$ajax_action
The instance of WP-Librarian's Dashboard action class WP_LIB_AJAX_ACTION. Access to this is necessary to handle completing the AJAX request properly.
$action_name
The name of the Dash action requested to be completed. When loaning an item the $action_name is 'loan'.
###Example
Suppose I want my fortune told with every dash action. I could use the function below:
add_action('wp_lib_dash_action', 'my_fortune');
function my_fortune(WP_LIB_AJAX_ACTION $ajax_action) {
// Your possible fortunes
$fortunes = array(
'Expect syntax errors ahead',
'Refactoring your code will reap great rewards',
'A forgotten problem will rear its ugly head',
'Your future is full of struggle and anguish. Most of it, self-inflicted',
'You must embrace the future or it will soon consume you'
);
// Chooses random fortune
$random_fortune = $fortunes[array_rand($fortunes)];
// Adds fortune to notification buffer, which is cleared when the AJAX request finishes
$ajax_action->addNotification($random_fortune);
}
And, as if by magic, every time I loan/return an item or perform any other Dash action:

###See Also
wp_lib_dash_action_ wp_lib_dash_page wp_lib_dash_page_ wp_lib_dash_api wp_lib_dash_api_