cannot get global $menu value in form request

I have register a route for edit_audience

register_rest_route( 'ilms_plugin', 'edit_audience', [
    'methods'   = 'POST',
    'callback'  = 'edit_audience',
    'permission_callback' = '__return_true',
]);

I try to get the global variable $menu in the edit_audience callback function.

function edit_audience($data) {
    global $menu, $submenu;
    error_log(menu=.print_r($menu, true).;);
    error_log(submenu=.print_r($submenu, true).;);
}

But nothing return from the $menu global variable.

I am doing this way to change the menu and submenu capability from a form request. Is there any way to change the menu and submenu capability with WordPress API.

Topic wp-api globals sub-menu capabilities menus Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.