Site icon Hip-Hop Website Design and Development

Unable to get wp_redirect() working after adding a CPT via the front end

I am attempting to learn PHP by creating a relatively simple application built on wordpress, it is a basic CRM and I’ve made decent progress but have been stuck on some of the finer points.

I’ve been having some serious ‘headers already sent’ problems with getting wp_redirect() working after a user creates a new customer.

Here is an example of what I want to do:

This code is placed after the HTML form.

I know wp_redirect() has to be called before the page starts outputting anything but I am unsure how to make that happen because I have tried putting it further up in the page but it doesn’t get me anywhere.

Feel free to abuse me for the terrible code and ambiguous question but if you could possibly point me in the right direction to accomplish what I am trying to achieve that would be great! I have tried to break things up into functions to get called via the ‘save_post’ hook but no luck with that either.

Thanks for reading!