Sunday, 15 January 2012

php - WordPress's wp_redirect() with add_query_arg() not updating global $_GET -


I use the page like this:
example.com?step=3
Even here, It works, if I use $ _ GET ['step'] it's okay, I use it 3.

But, after step 3 it needs to be done, I call:
Wp_redirect (add_query_arg ('step', 4));
Look at the Networks tab on Devtools and uses it with 302: example.com?step=4
but on the page $ _GET ['step'] still 3! In comparison, it enters the infinite loop.

I have logged in to $ _ server [[QUERY_STRING]] and it is expected step = 4 , but the next line on the right which I I call $ _ GET ['step'] and it's 3!

When I work directly from example.com, it works, $ _ GET ['step'] 4, but when I wp_redirect ( ); .

Can anyone help?

I think your problem is that you do not have the old "step" before adding a new one Are removed. The add_query_arg () does not update the string, it adds to it.

Then try to do something like this ...

  $ origURL = Remove_query_arg ('step'); Wp_redirect (add_query_arg ('step', 4, $ original URL));  

No comments:

Post a Comment