Developer // Removing Sub Page Menu Item In WordPress Whilst Still Allowing Page Access

Had an error in from a website where the admin couldn’t gain access to edit registrations in WordPress backend. Receiving the following “you are not allowed access” error:

wordpress access error

On closer inspection to the code it appeared in trying to hide the ‘Add New’ option for the post type from the admin menu, the developer had inadvertently removed access to the registration form page.

remove_submenu_page( 'registrations', 'registrations_form' );

Although this successfully removed the item from the post type menu, the same form used for new registrations was also used to edit the existing registrations. Meaning when the admin wanted to edit a registration they were refused access.

The solution, instead of removing the page completely, simply edit the code adding the ‘Add new’ menu item in the first place. Changing the first parameter, which is the parent menu item, from the post type name, which in this example is ‘registrations’, to instead be ‘null’.

Thus removing the menu item, but keeping the page functionality in tact.

// add new
null, // instead of 'registrations'
__('Add new', 'custom_table_example'),
__('Add new', 'custom_table_example'),


Leave a Reply

Your email address will not be published. Required fields are marked *