开发者

Extending Contact Form 7 Wordpress plugin by using hooks

开发者 https://www.devze.com 2023-01-06 15:22 出处:网络
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:

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 wor开发者_如何学Pythonk 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.


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).

0

精彩评论

暂无评论...
验证码 换一张
取 消