[wp-trac] [WordPress Trac] #58403: Running remove_menu_page in the theme will cause admin-ajax.php 500 errors
WordPress Trac
noreply at wordpress.org
Fri May 26 01:27:02 UTC 2023
#58403: Running remove_menu_page in the theme will cause admin-ajax.php 500 errors
--------------------------+------------------------------
Reporter: niau | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Menus | Version: 6.2.2
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------+------------------------------
Comment (by niau):
Replying to [comment:1 petitphp]:
> Hello @niau and welcome to trac.
>
> Looking at your example, you are calling the function `remove_menu_page`
during the `admin_init` action.
> According to
[https://developer.wordpress.org/reference/functions/remove_menu_page
/#more-information the documentation for this function], you should be
using the `admin_menu` action instead to avoid the error.
> The `admin_init` action is too early, and the menu is not ready to be
manipulated at this point.
>
> Can you try to change the hook and see if you still have the issue ?
Thanks, switching to 'admin_menu' solved my problem.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/58403#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list