Correct undefined variable in post_shared hook, fixes #2592

Fix for #2592