How to pass any arguments to an admin page via a new admin menu item?
-
For a plugin I’m writing I need to add a sub menu item to the Comments menu in admin dashboard.
No problem doing this with:
add_submenu_page('edit-comments.php',__('Comments'), 'Aggiungi Commento', 'edit_posts', 'dashboard-write-comments.php', 'write_comment_page');
But I need to pass an argument to the page that I’m calling (let say that I need to pass the post id).
I can’t find a way to do this without raising an error.
If I add any other value to the “file” argument of the add_submenu_page() funcion, WordPress trow out an “You do not have sufficient permissions to access this page.” error.
Example:add_submenu_page('edit-comments.php',__('Comments'), 'Aggiungi Commento', 'edit_posts', 'dashboard-write-comments.php&post='.$post_id, 'write_comment_page');
I tried both
dashboard-write-comments.php&post='.$post_id
anddashboard-write-comments.php?post='.$post_id
without any luck.I checked the core WP files and looks like that the error is triggered in wp-admin/menu.php, at the very end of the file, where it doeas a check with
user_can_access_admin_page()
Can’t understand why if the “link” has no arguments the “can access admin page” is ok but when I add any argument the check stop everithing…
Anyone can help? or suggest an other way?
- The topic ‘How to pass any arguments to an admin page via a new admin menu item?’ is closed to new replies.