I am developing a WordPress plugin that creates a page in the admin area for users to manage voters. I am extending the WP_List_Table to create the list of voters and I want to add custom bulk actions to it.

I am using the process_bulk_action function in order to create a custom action.

function process_bulk_action() {

    global $wpdb;

    if ('allocate' === $this->current_action()) {
        $user_id = get_current_user_id();
        $electionnums = isset($_REQUEST['electioncitizen_electionnum']) ? $_REQUEST['electioncitizen_electionnum'] : array();
        if (is_array($electionnums)){
            foreach ($electionnums as $electionnum) {
                $allocating_citizens = $wpdb->get_results('SELECT * 
                                                            FROM elap_citizens 
                                                            WHERE elap_citizen_electioncitizen_id = ' . $electionnum . '
                                                            AND elap_citizen_user_id = ' . $user_id . '
                                                            ORDER BY elap_electionindex_name ASC', ARRAY_A);
                    $result = $wpdb->insert( 
                                    'elap_citizen_electioncitizen_id' => $electionnum,
                                    'elap_citizen_user_id' => $user_id
        } else {
            $electionnums = implode(',', $electionnums);

Unfortunately WordPress doesn’t allow you to add custom bulk actions that way, only bulk actions that pre exist, like delete.

Is there a workaround this?

Read more here: Custom bulk actions for custom list table in WordPress plugin


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: