Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
    
Please show your complete code. From reading your question it is quite unclear what you are actually asking. –  kaiser Mar 12 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? –  Keir Lavelle Mar 12 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 at 14:22
    
Yes that is perfect, very nicely put thank you. –  Keir Lavelle Mar 12 at 14:25

1 Answer 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.

share|improve this answer
    
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 –  Keir Lavelle Mar 12 at 14:14
    
You need WorldPay to request your page? –  s_ha_dum Mar 12 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. –  Keir Lavelle Mar 12 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 at 14:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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