Moved add_action outside of the conditionals.