钩子名:cms_model_add_end
作用:前台用户发布表单之后的操作;
代码如下:
public function cmsModelAddEnd($info = [],$id = 0) { $nowtime = format_time(time(), 'Y年m月d日'); $sub_data = []; if ($info['plugin_name'] == 'form') { // 这里只适用于前台客户提交 $submit_num = fun("count@info", 'form_content' . $info['mid'], ['create_time' => fun('Time@only', 'day')]); //获取表单信息 $midinfo = Db::name('form_module')->where('id', $info['mid'])->find(); $url = purl('form/content/show',['id'=>$info['id']],'index'); if ($info['mid'] == 1) { $sub_data = [ 'url' => $url, 'content' => ['有用户提交了' . $midinfo['title'] . '表单,请尽快审核', config('webdb.webname'), '姓名:' . $info['title'] . ',电话:' . $info['telphone'], $nowtime, '该表单今日提交了' . $submit_num . '次(包含无效)'] ]; } elseif ($info['mid'] == 2 || $info['mid'] == 6) { $sub_data = [ 'url' => $url, 'content' => ['有用户提交了' . $midinfo['title'] . '表单', config('webdb.webname'), '姓名:' . $info['linkman'] . ',电话:' . $info['telphone'], $nowtime, '该表单今日提交了' . $submit_num . '次'] ]; } else { $sub_data = [ 'url' => $url, 'content' => ['有用户提交了' . $midinfo['title'] . '表单', config('webdb.webname'), $info['title'] . ',内容:' . $info['content'], $nowtime, '该表单今日提交了' . $submit_num . '次'] ]; } } return self::postsend($sub_data); }
安装钩子:
INSERT INTO `qb_hook` (`id`, `name`, `about`, `ifopen`, `list`) VALUES(0, 'cms_model_add_end', '前台用户发布表单后', 1, 0);