I have set up a plugin that because of the amount of data being used I set up a custom table and have extended the WP_List_Table class. I know that is not recommended, but Custom Post Types just won't offer what I need. I plan on including a copy of the WP_List_Table class when releasing this project to prevent any unwanted bugs...

Anyhow, I have the following code and have went through a lot of tutorials on extending the WP_List_Table class, but have hit a wall.

function column_name( $item ) {
  $title = '<strong>' . $item['projectName'] . '</strong>';

  $actions = [
    'edit'    => sprintf( '<a href="?page=%s&action=%s&project=%s">Edit</a>',
      $_REQUEST['page'], 'edit', $item['projectID'] ),
    'delete'  => sprintf( '<a href="?page=%s&action=%s&project=%s">Delete</a>',
      $_REQUEST['page'], 'delete', $item['projectID'] )

  return $title . $this->row_actions( $actions );

When I click edit, all that happens is a url change. I am not sure how to actually generate a form/admin page to edit/update a project when the edit button is clicked. I am also getting a redirection error when "delete" is clicked, which I plan on getting to later. I assume for delete I just need to make sure I have the proper SQL statement to remove the project from the database.

Thank you in advance for your help.

  • You'll need to register an admin page and implement the forms etc from scratch. Also some context as to why you needed custom tables would be helpful. It's very possible somebody has thought of something you haven't and you can sidestep all of this entirely – Tom J Nowell Aug 4 '17 at 21:59
  • Sorry for the late reply! It's a project management system. There are plenty out there, but it's for a project my grad team is stuck on. So we would make an admin page and then have that form on there, and could we use AJAX to pull the clicked on project's information into the form for editing? – Dylan Wagner Aug 7 '17 at 17:47

Apparently the right way to do this is to get the suffix returned by your custom page that normally displays the table and use it to hook into the page load before any admin content is rendered.

add_action('admin_menu', function() {
    $page_hook_suffix = add_submenu_page( # or related function
        function() {
            # content of table page
    if ($page_hook_suffix) {
        add_action("load-$page_hook_suffix", function() {
           # verify nonces, handle actions, redirect, etc.

Your Answer

