Answer the question
In order to leave comments, you need to log in
Is it possible to run a function to process records via bulk_actions-upload?
Nowhere I can find the necessary example to understand whether this is feasible and if so, how.
I created a custom action in the file library:
The task is to make it run a function that will process each selected image. The function is located in the theme's functions.php.
Here is the code itself:
add_filter('bulk_actions-upload', function($bulk_actions) {
$bulk_actions['run_custom_function'] = __('Custom Function', 'txtdomain');
return $bulk_actions;
});
add_filter('handle_bulk_actions-upload', function($redirect_url, $action, $post_ids) {
if ($action == 'run_custom_function') {
foreach ($post_ids as $post_id) {
//run the function
}
$redirect_url = add_query_arg('run_custom_function', count($post_ids), $redirect_url);
}
return $redirect_url;
}, 10, 3);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question