How to modify header data for admin pages?
-
Hello. I need to remove one of the GET parameters from client’s browser address bar to prevent duplicate operation. As far as I understand, the only way to do this server-side is to edit the Location header.
Here is a code snippet which is a part of an Order List page in WP Admin panel:
//display the contents of selected order if (isset($_GET['show_order'])) { //see if our user clicked "mark this order processed" if (isset($_GET['mark_as_processed'])) { //update order status via custom function that uses $wpdb->update update_order($_GET['mark_as_processed'], 'Processed'); //removing the mark_as_processed parameter from client's address bar //doesn't do anything add_action('send_headers', function() { header('Location: '.$_SERVER['HTTP_REFERER']); }); //doesn't do anything either, probably because wp_headers isn't called for admin pages add_filter('wp_headers', function($headers) { $headers['Location'] = $_SERVER['HTTP_REFERER']; return $headers; }); //wouldn't work too, obviosuly header('Location: '.$_SERVER['HTTP_REFERER']); } }Could anyone tell me what is wrong with my approach here? Note that the HTTP_REFERER global contains precisely what I need in this situation so it’s certainly not an issue here. The problem is that these add_filter or add_action functions don’t seem to perform any sort of operation on the headers being sent.
The topic ‘How to modify header data for admin pages?’ is closed to new replies.