Start a new topic
Solved

Custom actions after submission to an event

I would like to post event subscriptions to Hubspot as contacts. So, I looked if I could do it myself as post action hook after successful subscription but I can't find anywhere in your docs a description how can I do this?

In pseudo-code I wanted something like:


add_action('mec_user_subscribed''custom_mec_user_subscribed'102);

 

function send_user_info_to_hubspot($email$first_name$last_name) {

$data = json_encode([ ...

 $response = wp_remote_post($endpoint, [

        'body'    => $data,

        'headers' => [

            'Content-Type' => 'application/json',

            'Authorization' => 'Bearer ' . $hubspot_api_key

        ]

    ]);

 

Or do you perhaps recommend another way to to do this?


Hello,


Thank you for posting on our forums.

We do not have an option for what you want. You can submit a feature request for it: https://my.webnus.net/feature-request/
Or

You can request a custom development service:  https://forms.gle/ut89gd36wEVgZLPJ8

Coding is not part of Webnus' support for it's products.


A third way is to integrate MEC with the services we have integration with such as the ones you can see in this screenshot. These function the same as hubspot


Best,

Webnus Team

Thank you for prompt reply. I have submitted this as a feature request. 

Meanwhile i made this working with custom code on functions.php (which i am not super proud of but it seems to work). 

1. I binded to hook add_action('mec_booking_verified', 'custom_mec_booking_verified', 10, 2);
2. then on custom function I am:
 // Retrieve booking metadata
$meta_data = get_post_meta($booking_id);

 

I found data I need on mec_attendees

unserialize
($meta_data['mec_attendees'][0]);

Loop  it through: 

 

     $name = $attendee['name'];

                $email = $attendee['email'];

Loop  it through and send info to:

 

send_user_info_to_hubspot($email, $name


Then use Hubspot REST  API to inject name and email:

 

 $data = json_encode([

        'properties' => [

            ['property' => 'email', 'value' => $email],

            ['property' => 'firstname', 'value' => $first_name],

            ['property' => 'lastname', 'value' => $last_name],

 

        ],

    ]);


    $response = wp_remote_post($endpoint, [

        'body'    => $data,

        'headers' => [

            'Content-Type' => 'application/json',

            'Authorization' => 'Bearer ' . $hubspot_api_key,

        ],

    ]);

 

Login or Signup to post a comment