Is it possible to redirect a user in WP without the header/wp_redirect being before header()?
I have a plugin that allows users to manage content they have created on the site… for example, they can delete it or disable comments
It’s quite basic so i’m just using a GET request.. ie.
?action=comments&status=disable
When this button is click the action is performed but nothing happens on the page and the url is now: www.domain.com/user_data?action=comments&status=disable
what I want to do is on success redirect the user back to www.domain.com/user_data
I have tried wp_redirect() and header() but they give ‘headers already sent warnings’
I’m not sure how i can put that before the header when this code is within my plugin.
$query = $this->db->update(
//do something
);
if($query == 0)
{
$this->setMessage('error', 'There was an error: ' . $this->db->print_error());
}
else
{
wp_redirect(site_url('/user_data/'));
}