This is just a quick tip, something that I faced a while ago while working on a client’s website.
I had to develop a shortcode responsible to render a form and obviously after the submission I wanted to redirect the user to another url (following the POST/redirect/GET pattern).
It may seem easy but using something like wp_redirect directly in the shortcode rendering block may cause errors like this:
Warning: Cannot modify header information - headers already sent by ...
One possible (and very easy) solution is to register a function for the template_redirect hook and handle everything there. Something like this:
of course don’t forget to create an instance of the class!