Support » Fixing WordPress » Lock a page and prevent deletion

  • Just a general query… is it possible to create a Page and then to lock it? e.g. prevent it from being unpublished or deleted.

    Whilst developing some themes, its nessessary to hard-code certain IDs for pages (when you’re creating navigation or pulling in content from another page). Once the website is handed over to the client and they are let loose on the system, there is the opportunity for them to delete a vital page – which in turn would “break” the website.

Viewing 3 replies - 1 through 3 (of 3 total)
  • I don’t think there is a way to lock a page, but perhaps in your theme you should write a check to see if the page with a given ID exists, and if not, don’t display a link or any code for it. This way, if the client deletes the page, it won’t break the site. It will of course lose the information, but that isn’t necessarily your fault.

    You may also consider using constants you can set in the wp-config.php file, then have your theme use the constants. Something like

    define('SPECIAL_PAGE', 5)

    where 5 is the page ID. This way, if they delete the page, and you need to recreate it, you can change the wp-config.php to the correct ID of the new page, and the theme works again.

    If you don’t want to edit the wp-config.php, you can also set these constants in the functions.php file for your theme.

    Many thanks. Thats an option I shall definitely take on board.

    You could take a look at this plugin:

    I may or may not work for single-installs of WP

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Lock a page and prevent deletion’ is closed to new replies.