post parameter ‘name’ 404 error

I am integrating the WorldPay hosted payment pages gateway to my WordPress installation and I am setting a notification URL in WorldPay to a route within WordPress.

The problem I am having is that WordPress automatically responds with a 404 error if you pass it a parameter called ‘name’, or any other reserved term as defined here: WordPress reserved Terms as WorldPay does.

Read More

I was wondering whether it is possible to change this default 404 response, I have tried using unset($_POST['name']) within my plugin code, but I assume that this is too late within the request lifecycle as it didn’t alter the response. I would also prefer not to set my callback url to another script, which would then alter the $_POST array and pass it on to my plugin, if anyone can suggest a way I can achieve a 200 response without doing this?

edit: My question in a much easier to read format

Remote service X is sending a callback to my WordPress site of example.com/?name=nameofaccount how do you handle that when WordPress uses name as a reserved term and the remote service wont change?

Related posts

1 comment

  1. It sounds as though WorldPay is responsible for sending the overly generic name parameter so you aren’t in a position to control that. You will instead have to catch the request and force it to work. Something like:

    function redir_404_wpse_137703() {
      if (is_404() && isset($_GET['name'])) {
        locate_template('some-theme-template.php',true);
        exit;
      }
    }
    add_action('template_redirect','redir_404_wpse_137703');
    

    some-theme-template.php will need to be constructed with get_header(), content, and get_footer() like normal custom templates.

    The big problem I see is sorting out genuine 404s from WorldPay ones but there must be other parameters that would help sort that out.

Comments are closed.