1

I'm writing my first plugin for WordPress and am running into a permission issue when trying to pass a parameter to a page.

I've added a submenu page to process a delete for a category from the database when the user navigates to the link.

However, when you navigate to the specific URL, I am getting the error:

You do not have sufficient privileges to access this page.

Here is the adding of the submenu page:

add_submenu_page( null, 'Delete Category', 'Delete Category', 'administrator', 'ecosystem-delete-category );

All of the categories have a Delete link next to them and when the user clicks on the link for a category they are redirected to the url with the passed in ID parameter.

echo '<td><a href="/wp-admin/admin.php?page=ecosystem-delete-category?id=' . $categoryId . '">Delete</a></td>'

And then this is what I have on my ecosystem-delete-category page:

$id = $_GET['id'];
global $wpdb;
$table_name = $wpdb->prefix . "ecosys_category";
$wpdb->delete( $table_name, array( 'category_ID' => $id) );

I believe my issue is with passing the parameter but maybe I'm wrong. Any help would be appreciated!

2
  • You're adding a submenu page with no menupage at all - a null parameter!! Mar 11, 2016 at 16:03
  • @MayeenulIslam Yes, that is intentional. I do not want to display the submenu page in the actual submenu. So by passing null, it essentially "hides" it from the menu.
    – Dev 404
    Mar 11, 2016 at 16:05

1 Answer 1

0

Continued to do more research and ended up finding the solution to my problem! Since the url I am passing the parameter to is /wp-admin/admin.php?page=ecosystem-delete. I didn't even notice that ?page=ecosystem-delete is already a parameter, so I needed to pass my second parameter into the URL as &id= rather than ?id=.

A simple overlooked mistake. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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