doutan8601 2014-08-02 19:12
浏览 62
已采纳

PHP / Wordpress / Woocommerce:防止读取url参数

I was wondering if it would be possible to prevent url parameters from being read and used via PHP, specifically with Wordpress and Woocommerce.

The best example I can give is as follows, for a domain with wordpress and woocommerce installed, the following URL will add the appropriate product (with product id 999) to cart instantly:

www.example.com/?add-to-cart=999

I would like to prevent this parameter from being read if possible. All assistance is appreciated.

  • 写回答

1条回答 默认 最新

  • doz15449 2014-08-08 17:56
    关注

    Alright, solved it, sort of. No GET Requests will go through on that particular parameter.

    Edit class-wc-form-handler.php (found within the woocommerce/includes directory where your wordpress plugins are found) as follows:

    find the function add_to_cart_action and add the following directly under the method declaration:

    if ( $_SERVER['REQUEST_METHOD'] == 'GET'){
            return;
        }
    

    All done, probably not the best answer, but it gets the job done.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 这个复选框什么作用?
  • ¥15 单通道放大电路的工作原理
  • ¥30 YOLO检测微调结果p为1
  • ¥20 求快手直播间榜单匿名采集ID用户名简单能学会的
  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合