Has anyone successfully integrated Memberpress into Pipedrive ?

alexis denorme
alexis denorme Member Posts: 1 VERIFIED MEMBER
edited July 2022 in Sales CRM #1

I try to integrate contact between Memberpress and Pipedrive but my code doesn't work actually, however I used the code given by pipedrive in its doc.

My code :

<?php

/*

Template Name: CRM Member Template

*/

 

 

//get_header();

$current_user_id = get_current_user_id();

$phone = get_user_meta($current_user_id,'mepr_telephone',true);

$nom = get_user_meta($current_user_id, 'last_name', true);

$prenom = get_user_meta($current_user_id, 'first_name', true);

$age = get_user_meta($current_user_id, 'mepr_age', true);

$username_etoro = get_user_meta($current_user_id, 'mepr_nom_utilisateur_etoro', true);

 

global $current_user;

get_currentuserinfo();

$email = $current_user->user_email;

$username = $current_user->display_name;

 

error_log('User Infos');

error_log($nom);

error_log($prenom);

 

// Content of create_deal.php

// Pipedrive API token

$api_token = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';

$person = array(

'name' => $nom,

'phone' => $phone,

'email' => $email,

'org_id' => "1",

'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' => $prenom, //Prenom

'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' => $age, //Age

'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' => $username_etoro, //Etoro

'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' => $username, //UserWP

);

 

error_log('Person Infos');

error_log(print_r($person, true));

 

// Person's ID

 

// URL for updating a Person

$url = 'https://xxxxxxxxxxx.pipedrive.com/v1/persons?api_token=' . $api_token;

 

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

curl_setopt($ch, CURLOPT_POST, true);

curl_setopt($ch, CURLOPT_POSTFIELDS, $person);

 

//echo 'Sending request...' . PHP_EOL;

 

$output = curl_exec($ch);

curl_close($ch);

 

// Create an array from the data that is sent back from the API

// As the original content from server is in JSON format, you need to convert it to PHP array

error_log('Result API');

error_log(print_r($output, true));

 

$result = json_decode($output, true);

 

error_log('Result API JSON DECODE');

error_log(print_r($result, true));

 

// Deal title and Organization ID

 

// Check if an ID came back, if did print it out

if (!empty($result['data']['id'])) {

 update_user_meta($current_user_id, 'mepr_pipe_id', $result['data']['id']);

}

 

wp_redirect( '/xxxxxxxxxxxxxx' );

exit;

?>

 

<?php while (have_posts()) : the_post(); ?>

 <?php get_template_part('templates/page', 'header'); ?>

 <?php get_template_part('templates/content', 'page'); ?>

<?php endwhile; ?>

 

Thank you for your help ^^.

Comments

This discussion has been closed.