resubmission - hooks for security and customization

Resubmitting pull request 3895. Combined 2 hooks in succession into a single hook, and used location to name hooks.