How to remove access to menu options in admin panel

How can I restrict access to menu or submenu items in WordPress admin dashboard according to the user’s role ?

This function allow to restrict access to an element by url (e. g. /wp-admin/upload.php) or depending on the url parameter (e. g. post_type=acf_option_page) which is very useful to remove access to custom post type.

Insert this code on your functions.php file or plugin:



Please not that this function only remove the access, but the menu items will remain visible!

Submit a Comment

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