douao1858 2019-07-16 21:07
浏览 42

在文件夹类页面之后,将忽略来自url的GET变量

At work (well more like an apprenticeship, dunno) I'm making a wordpress plugin that allows users to submit their posts (it's for a website catalog) with the ability to pay for some premium features. For this I'm using PayU.
I have a shortcode which I put on a page where users end up after the payment, and the shortcode shows appropiate message depending on GET variables. Eg. "your post awaits moderation" with a free post, "payment was successful" when it was so etc.

So when payment in PayU fails it will stick &error=501 to the end of the url, so my code detects that and tells the user their payment failed and their post won't be submitted. And here's the thing. When the confirmation page url is itself a variable, eg. ?post_id=71, everything works as expected. So for mywebsite.com/?post_id=71&posttype=paid&error=501 the error is read and shortcode acts appropiately. But when the address in folder-like (sorry, really dunno how to call that) eg. /confirmation, error variable gets unnoticed. So with an address like mywebsite.com/confirmation?posttype=paid&error=501 the result is a "payment successful" message. Order of variables doesn't seem to matter, posttype is always interpreted and error is always omitted.

I don't have access to the code right now but it's basically this:

function my_shortcode() {
    if(!isset($_GET['posttype'])) {
        // some generic text to handle this unexpected condition
    }
    else if($_GET['posttype'] == 'free') {
        // nice message on how the post awaits moderation
    }
    else if($_GET['posttype'] == 'paid') {

        if(isset($_GET['error'])) {
            if($_GET['error'] == '501') {
                // payment was unsuccessful
            } else {
                // some generic text cause this isn't supposed to happen too
            }
        } else {
            // payment was successful
        }
    }
}

As I said, I'd expect the error value to modify the behavior accordingly, instead it only does so when page address is itself a query.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 求帮我调试一下freefem代码
    • ¥15 R语言Rstudio突然无法启动
    • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
    • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
    • ¥15 用windows做服务的同志有吗
    • ¥60 求一个简单的网页(标签-安全|关键词-上传)
    • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图