• Resolved Abatap

    (@abatap)


    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']);
        }
    }

    Can anyone tell me what is wrong with my approach? Note that the HTTP_REFERER global contains preciesly 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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Bet Hannon

    (@bethannon1)

    Looks like you got this resolved. Care to share how you did it so that it might help someone else with a similar question?

    Thread Starter Abatap

    (@abatap)

    Oh, I didn’t find any solition. The reason I’ve marked this topic resolved is because of realizing it was posted in a wrong section of the forum. Sorry. Can you delete this thread btw?

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘How to modify header data for admin pages?’ is closed to new replies.