WordPress.org

Ready to get started?Download WordPress

Forums

Contact-Form-7: 3rd-Party Integration
[resolved] How to interract with CF7 fields using hooks (3 posts)

  1. s.edel
    Member
    Posted 2 years ago #

    Hi,

    I try to interract with SugarCRM using 3rdparty service for Contact-Form-7.
    In documentation, i found that I need to use Hooks. Ok, nice.
    So I check the hooks option and now I have the following : add_filter('Cf73rdPartyIntegration_service_filter_post_5', array(&$this, 'YOUR_FILTER'), 10, 4);
    I need to insert something to functions.php.

    But what and where ???
    I found functions.php but I'm not sure is the good one.

    Does someone has an easy sample of using add_filter with function prototype, etc.

    Thanks.
    Regards,
    s.edel

    http://wordpress.org/extend/plugins/contact-form-7-3rd-party-integration/

  2. s.edel
    Member
    Posted 2 years ago #

    I've found how to use add_filter hooks.
    Here is a step by step of what I do :

    1)
    copy file
    /wp-content/plugins/contact-form-7-3rd-party-integration/3rd-parties/listrak/functions.listrak.php
    to folder
    wp-content/themes/cloriatotheme/cloriatotheme/functions/
    rename it like you want (i.e 3rdparty-services-filters.php)
    (Note that your destination folder name depends on your theme)

    2)
    edit functions.php situated in your theme folder and insert a line to include your filters.php file
    like this : require_once ($functions_path . '3rdparty-services-filters.php');

    3)
    edit filters.php file to add your own filter / convertion logic

    <?php

    if(!class_exists('Cf73rdParty_ListrakCallbacks')):

    class Cf73rdParty_ListrakCallbacks {
    public function __construct(){
    add_filter('Cf73rdPartyIntegration_service_filter_post_5', array(&$this, 'sugar_filters'), 10, 4);
    }

    public function sugar_filters($values, &$service, &$cf7){
    if (isset($values["description"]))
    {

    $array = $values["description"];
    // Convert var if it's an array
    if (is_array($array))
    $values["description"] = implode(", ", $array);
    }

    return $values;
    }
    }

    $cf73rdpartycallback_instance = new Cf73rdParty_ListrakCallbacks();
    endif; //class-exists
    ?>

    Regards,
    S├ębastien

  3. zaus
    Member
    Plugin Author

    Posted 1 year ago #

    Glad you figured out the solution. Is there anything I can do in the documentation to make stuff like this easier to find?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic