I have a plugin that creates a menu page on admin dashboard:
function dp_manage_admin_menu() {
add_menu_page('Manage Data', 'Manage Data', 'manage_options', 'manage-data', 'dp_manage_data_page', '');
add_submenu_page('manage-data', 'Add New', 'Add New', 'manage_options', __FILE__ . '/add-new', 'tm_add_new_page');
}
// Actions
add_action('admin_menu', 'dp_manage_admin_menu');
In that page manage-data
, There is a button for deleting data from DB:
<a href="<?php echo admin_url() ?>admin.php?page=manage-data/manage-data.php?id=<?php echo (isset($result->id)) ? $result->id : ""; ?>" class="btn btn-danger btn-sm">
<i class="fa fa-trash-o"></i> Delete
</a>
So if I clicked the first button it goes to "http://example.com/wp-admin/admin.php?page=manage-data?id=1"
Then I check if the id
is sent, Then delete that result:
if( isset($_GET['id']) ){
//Do something.
}
But I get an error, When I click the delete button:
Sorry, you are not allowed to access this page.
I can visit "http://example.com/wp-admin/admin.php?page=manage-data", But if any parameters are sent I can't access it anymore.