I have extended WooCommerce to create a custom endpoint. This endpoint, points to a template that has a form to save user meta data. When the form is submitted I want it to redirect to another URL. Until I added
add_action( 'init', array($this, 'ob_function')); this was giving me a "headers already sent" error message. (
ob_function simply contains
My question is, should I be doing it this way? I've taken a look at some examples, have read up on it, etc but am unsure if this is bad practice (even though it works) as I guess that this is declaring
ob_start every time
init is loaded. I tried using conditional logic for the endpoint URL to restrict
ob_start being declared when this destination was the URL but kept receiving the aforementioned 'headers already sent' error message.