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);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 soildworks装配体的尺寸问题
  • ¥100 有偿寻云闪付SDK转URL技术
  • ¥30 基于信创PC发布的QT应用如何跨用户启动后输入中文
  • ¥20 非root手机,如何精准控制手机流量消耗的大小,如20M
  • ¥15 远程安装一下vasp
  • ¥15 自己做的代码上传图片时,报错
  • ¥15 Lingo线性规划模型怎么搭建
  • ¥15 关于#python#的问题,请各位专家解答!区间型正向化
  • ¥15 unity从3D升级到urp管线,打包ab包后,材质全部变紫色
  • ¥50 comsol温度场仿真无法模拟微米级激光光斑