使用钩子扩展Contact Form 7 WordPress插件

发布于 2024-09-08 07:49:14 字数 580 浏览 1 评论 0原文

我想创建一个使用联系表单 7 挂钩 wpcf7_admin_after_mail 的插件。我想使用该插件与 CRM 系统交互。到目前为止我所拥有的是以下内容:

//plugin header here

function add_to_CRM( $cf7 )
{
    if (isset($cf7->posted_data["your-message"]))
    {
        full_contact($cf7);
    } else {
        quick_quote($cf7);
    }
    return $cf7;
}

add_action('wpcf7_admin_after_mail', 'add_to_CRM');

//other functions here

我似乎无法让这个工作。我什至无法让钩子工作并做诸如给我发邮件之类的事情。任何人都知道我在这里做错了什么。由于我的 WordPress 经验有限,我可能完全错过了我在这里尝试做的事情。我用谷歌搜索了无数个答案。

编辑:我最终将其添加到主题的functions.php 文件中,并且它运行完美。问题是,我想让它作为插件工作。任何帮助将不胜感激。

I would like to create a plugin that uses the contact form 7 hook, wpcf7_admin_after_mail. I want to use the plugin to interface with a CRM system. What I have thus far is the following:

//plugin header here

function add_to_CRM( $cf7 )
{
    if (isset($cf7->posted_data["your-message"]))
    {
        full_contact($cf7);
    } else {
        quick_quote($cf7);
    }
    return $cf7;
}

add_action('wpcf7_admin_after_mail', 'add_to_CRM');

//other functions here

I can't seem to get this working. I can't even get the hook to work and do something like mail me. Anybody have any idea what I'm doing wrong here. Since I have limited Wordpress experience I might me missing the boat completely with what I'm trying to do here. I've Googled for answers to no end.

EDIT: I ended up adding this to the theme's functions.php file and it works perfectly. Thing is, I want to get it working as a plugin. Any help will be appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鲜血染红嫁衣 2024-09-15 07:49:14

尝试延迟 add_action() 调用,例如;

add_action('init', create_function('',
    'add_action("wpcf7_admin_after_mail", "add_to_CRM");'));

一旦 WordPress 准备好(接近 functions.php 加载的时间),这实际上会注册您的 CF7 挂钩。

Try delaying the add_action() call, something like;

add_action('init', create_function('',
    'add_action("wpcf7_admin_after_mail", "add_to_CRM");'));

This actually registers your CF7 hook once WordPress is ready (which is nearer the time functions.php gets loaded in).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文