Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a custom wp_list_table to create my own table. Almost everything works perfect, but the bulk action button seems to be not working. It's proper displayed,but on click nothing happens. I think somehow there is a form-wrapper missing or just some javascript? I added the button described on wp-engineeers: http://wpengineer.com/2426/wp_list_table-a-step-by-step-guide/#bulk

My Bulk-action functions:

function get_bulk_actions() {
    $actions = array(
        'activate'    => __('Show'),
        'deactivate'  => __('Hide')
    );
    //Add delete function for admins
    if(current_user_can( 'delete_published_posts' )){
        $actions['delete'] = __('Delete');
    }
    return $actions;
 }

    function process_bulk_action() {

        $action = $this->current_action();
        if( 'activate'===$action ) {

          foreach($_GET['wp_list_event'] as $event) {
                echo($event['title']);
            }

        }
        if( 'deactivate'===$action ) {
          wp_die('Items deactivated (or they would be if we had items to deactivate)!');
        }
        //Detect when a bulk action is being triggered...
        if( 'delete'===$action ) {
          wp_die('Items deleted (or they would be if we had items to delete)!');
        }
    } 

The rendered HTML (not wrapped by any form tag)

<div class="alignleft actions">
  <select name='action'>
    <option value='-1' selected='selected'>Aktion wählen</option>
    <option value='activate'>Anzeigen</option>
    <option value='deactivate'>Verstecken</option>
  </select>
  <input type="submit" name="" id="doaction" class="button action" value="Übernehmen"  />
</div>
share|improve this question

2 Answers 2

up vote 4 down vote accepted

You need to wrap your table into form tag, otherwise your bulk action button won't work.

share|improve this answer
    
Thanks, that did it. –  abimelex Sep 10 '13 at 10:07

this lines from Custom List Table Example Plugin the solved the issue:

   <form id="events-filter" method="get">
    <input type="hidden" name="page" value="<?php echo $_REQUEST['page'] ?>" />
    <?php
      $wp_list_table->display();
    ?>
    </form>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.