Is it possible to restrict access to specific pages in the admin area based on the page slug?

I would like to restrict access to specific pages in the admin area to only the admin role (and / or specific users). There appears to be no shortage of answers on how to do this using the page ID’s – but I can’t seem to find any examples of how to do this with a page slug.

Extended explanation:
I have a list of pages (slugs are: login, logout, lostpassword, register, and resetpass) that I utilize across multiple websites in order to create corresponding pages that match the rest of the theme. But these are pages that are never directly edited and their presence to editors, contributors, etc. is unnecessary, possibly confusing, and certainly not anything I would want them to try and edit or delete.

Since page ID’s can vary from site to site, it would be handy to have a function that I could simply copy and paste and not have to worry about it. Thank you for taking the time to read this question and for any answers that might be contributed!

Read more here: Is it possible to restrict access to specific pages in the admin area based on the page slug?

Leave a Reply

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