使用挂钩扩展Contact Form 7 Wordpress插件 [英] Extending Contact Form 7 Wordpress plugin by using hooks

查看:75
本文介绍了使用挂钩扩展Contact Form 7 Wordpress插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

我似乎无法获得加工。我什至无法上班,也无法做类似给我发邮件的事情。有人知道我在这里做错了什么。由于我在Wordpress方面的经验有限,因此我可能会完全想不通在这里尝试做的事情。我已经用Google搜索了无休止的答案。

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.

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

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.

推荐答案

尝试延迟 add_action()呼叫,类似;

Try delaying the add_action() call, something like;

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

一旦WordPress准备就绪,这实际上会注册您的CF7钩子(时间更短了 functions.php 被加载)。

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

这篇关于使用挂钩扩展Contact Form 7 Wordpress插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆