Simple Membership to SuiteCRM

Simple Membership to SuiteCRM

Simple Membership is fast and easy way to make WordPress a membership site. We at Minami R&D just wanted to connect membership sign up to Suite CRM. So this is a simple memorandum to realize this.

Steps to take, first in Suite CRM

  • Create campaign in Suite CRM.
  • Create Personal Form in Suite CRM, Lead.
  • Personal form should include First name, Last name, email, and some other Lead attributes.
  • Copy the <form></form> part from the script for later use.

Next, in WordPress:

  • Add Simple Membership and enable registration form.
  • Go “Appearance > Theme Editor > (select from right bar) Function.php
  • Add in the last part of Function.php:
function after_registration_callback ($member_info)
//Form action URL from SuiteCRM Form
$url = '';

//The data you want to send via POST
//Assign Simple Membership registration fields to those
//of SuiteCRM Lead.
//$member_info has first_name, last_name, email.
//And add campaign_id, redirect_url, assigned_user_id,
//and moduleDir as appeared in SuiteCRM form as well.
$fields = [
    'Submit'            => 'Submit',
    'first_name'        => $member_info['first_name'],
    'last_name'         => $member_info['last_name'],
    'email1'             => $member_info['email'],
    'campaign_id' => 'xxxxxxxxxxxxxxxxxxxxxxxxx',
    'redirect_url' => 'xxxxxxxxxxxxxxxxxxxxxxxxx',
    'assigned_user_id' => 'xxxxxxxxxxxxxxxxxxxxxxxx',
    'description' => 'New membership from your wordpress.',
    'moduleDir' => 'Leads'

//url-ify the data for the POST
$fields_string = http_build_query($fields);

//open connection
$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, true);
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);

//So that curl_exec returns the contents of the cURL; rather than echoing it
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true); 

//execute post
$result = curl_exec($ch);
echo $result;

add_action('swpm_front_end_registration_complete_user_data', 'after_registration_callback');

Now, joining your WordPress site will make a Lead entry in your Suite CRM.

While this can create new lead in Suite CRM, the original Suite CRM lead has limited fields – maybe you want to include some additional information about who joins your website.

I will try to explain it in next post.