使用钩子扩展Contact Form 7 WordPress插件
我想创建一个使用联系表单 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试延迟
add_action()
调用,例如;一旦 WordPress 准备好(接近
functions.php
加载的时间),这实际上会注册您的 CF7 挂钩。Try delaying the
add_action()
call, something like;This actually registers your CF7 hook once WordPress is ready (which is nearer the time
functions.php
gets loaded in).