0

I have a plugin that I've written that is trying to call the gforms_after_submission hook. For some reason it isn't calling the function. I see in Gravity Forms documentation that it says I have to call gform_after_submission from the functions file - is there any reason I can't call it from the plugin? I've tested with the mail function, and the function admin_init is triggering.

<?php

class Infusionsoft_GformsPDF {
public function __construct() {
    add_action( 'admin_init', array( $this, 'admin_init' ) );
}

/**
 * Should call my function, but doesn't
 */
public function admin_init() {
    add_action('gform_after_submission', 'handle_file', 10, 2);
}

/**
 * Get the file URL and post it to Infusionsoft
 */

    public function handle_file($entry, $form){
        mail('myemail@email.com', 'Handle File was triggered', 'yippee');
    }
}
4

1 回答 1

0

这里的问题是您已将函数调用添加到admin_init钩子中。该admin_init钩子仅在用户访问管理区域时触发,但您在此处提交表单,该操作发生在管理区域之外的站点前端。

这是一个简单的修复 :-) 只需使用前端初始化钩子代替 -init

另请查看此参考,了解通常在页面加载时运行的操作,在您的网站前面和管理区域:

http://codex.wordpress.org/Plugin_API/Action_Reference

于 2014-04-10T15:06:19.353 回答