• Hello, I try to import contact information from memberpress register to my CRM pipedrive contact but with the API nothing is going on. Thanks for your help ^^.

    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);
    $id_partenaire = get_user_meta($current_user_id, 'mepr_id_chez_notre_partenaire', 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 = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
    $person = array(
    'name' => $nom,
    'phone' => $phone,
    'email' => $email,
    'org_id' => "1",
    'xxxxxxxxxxxxxxxxxxxxxxxxx' => $prenom, //Prenom
    'xxxxxxxxxxxxxxxxxxxxxxxxx' => $age, //Age
    'xxxxxxxxxxxxxxxxxxxxxxxxx' => $id_partenaire, //Age	
    'xxxxxxxxxxxxxxxxxxxxxxxxx' => $username, //UserWP
    );
    
    error_log('Person Infos');
    error_log(print_r($person, true));
    
    // Person's ID
    
    // URL for updating a Person
    $url = 'https://XXXXXXXXX.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']);
    }
    
    ?>
    
    <?php while (have_posts()) : the_post(); ?>
      <?php get_template_part('templates/page', 'header'); ?>
      <?php get_template_part('templates/content', 'page'); ?>
    <?php endwhile; ?>
Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    What gets error logged and what is not will better indicate where the problem lies. Without more specific information, we cannot even guess about what the problem might be. Because an external API is involved, the help we might be able to provide here is minimal at best.

Viewing 1 replies (of 1 total)

The topic ‘Integration Memberpress x Pipedrive’ is closed to new replies.