1

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.

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?

3
  • Please show your complete code. From reading your question it is quite unclear what you are actually asking.
    – kaiser
    Mar 12, 2014 at 13:28
  • My code is of no relevance unfortunately, as the post back to my website is initiated by WorldPay - I wish to be able to handle a post request that contains a parameter called 'name', if that is alittle more succint for you? Mar 12, 2014 at 13:46
  • I read it as: 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?
    – Tom J Nowell
    Mar 12, 2014 at 14:22

1 Answer 1

2

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.

4
  • Thanks for this, and sorry for the lack of clarity in my initial question, but I would like to actually modify the HTTP status code that is returned, i.e. return a 200 response, as it is the http status code is what is causing WorldPay to disregard the response body Mar 12, 2014 at 14:14
  • You need WorldPay to request your page?
    – s_ha_dum
    Mar 12, 2014 at 14:20
  • WorldPay sends a transaction notifcation to a URL I define in WorldPay, this notification is in the form of a POST request, one of the parameters of this POST request is 'name' which WordPress detects and automatically returns a 404 response. I would like to be able to bypass WordPress's detection of this parameter, or change the response if possible. Mar 12, 2014 at 14:22
  • Why not just use a subdomain for the World Pay Request and use a simple PHP script to manage the response and then move to the page you need with in wordpress?
    – Jane T
    Mar 12, 2014 at 14:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.