donglei1973 2018-05-29 01:28
浏览 52
已采纳

在重力表单上删除文件附件

I need to delete the files from the server every 15 days because it is overloaded on my server. So I tried to get all the file url in wp_rg_lead and wp_rg_lead_detail table. My question is there a hook or filter that can delete the file using the URL only? I know Wordpress has a wp_delete_attachment hook, but it is only for the WP media library.

This is my code

global $wpdb;
$get_data = $wpdb->get_results("SELECT tbl2.lead_id, tbl2.form_id,
tbl2.value FROM ".$wpdb->prefix."_rg_lead tbl1 LEFT JOIN ".$wpdb->prefix."_rg_lead_detail 
tbl2 ON tbl1.form_id=tbl2.form_id WHERE 
tbl1.date_created < DATE_SUB(DATE(now()), INTERVAL 15 DAY) 
AND tbl2.value LIKE '%/wp-content/uploads/gravity_forms/%' ");

foreach($get_data as $data){
    //delete hook?
}
  • 写回答

1条回答 默认 最新

  • doutou7961 2018-06-04 05:06
    关注

    After days of work I tried the unlink function of PHP I write it here.

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

报告相同问题?

悬赏问题

  • ¥20 keepalive配置业务服务双机单活的方法。业务服务一定是要双机单活的方式
  • ¥50 关于多次提交POST数据后,无法获取到POST数据参数的问题
  • ¥15 win10,这种情况怎么办
  • ¥15 如何在配置使用Prettier的VSCode中通过Better Align插件来对齐等式?(相关搜索:格式化)
  • ¥100 在连接内网VPN时,如何同时保持互联网连接
  • ¥15 MATLAB中使用parfor,矩阵Removal的有效索引在parfor循环中受限制
  • ¥20 Win 10 LTSC 1809版本如何无损提升到20H1版本
  • ¥50 win10 LTSC 虚拟键盘不弹出
  • ¥30 微信小程序请求失败,网页能正常带锁访问
  • ¥15 Matlab求解微分方程,如何用fish2d进行预优?