dsv17139 2014-12-16 15:49
浏览 60
已采纳

挂钩Drupal Webform提交

I'm developing a Drupal 7 website. The website has a couple of forms which take a users email address. As part of the process I need to be able to submit the email to a mailing list across an API.

I have all the calls written and tested for adding new users to mailing lists etc. What I'm not so sure of is how I get this code to run when the form is submitted on the Drupal site.

I assume there will be a hook function but I'm struggling to track it down. My forms are setup using Webforms module.

  • 写回答

1条回答 默认 最新

  • dongya4335 2014-12-16 17:49
    关注

    Use hook_form_alter() to hook in your webform instance & add an additional submit handler:

    /**
     * Implements hook_form_alter().
     */
    function hook_form_alter(&$form, $form_state, $form_id) { 
        if ($form_id == 'webform_client_form_{some id}')
        {
            array_unshift($form['#submit'], 'custom_webform_submit');
        }
    }
    

    Next in custom_webform_submit() execute your custom code:

    function custom_webform_submit($form, $form_state) {
        // custom code here
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

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