WordPress.org

Ready to get started?Download WordPress

Forums

Lock a page and prevent deletion (4 posts)

  1. Ryan Ball
    Member
    Posted 5 years ago #

    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.

  2. GrandSlambert
    Member
    Posted 5 years ago #

    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.

  3. Ryan Ball
    Member
    Posted 5 years ago #

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

  4. ccagle8
    Member
    Posted 4 years ago #

    You could take a look at this plugin: http://www.cagintranet.com/archive/wpmu-protect-pages/

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

Topic Closed

This topic has been closed to new replies.

About this Topic