Only run posthook when defined