Integrate your WordPress Site with Highrise using a Plugin

Highrise and WordPress, both are the most used applications in their own fields. Integrating Highrise with WordPres can bring in automation, reduce the human efforts and prove to be more advantageous.

Unfortunately, there is no ready-made plugin available, that can enable this efficiently. Here in this post, we will make a plugin that integrates the WordPress and the Highrise CRM. With this plugin when a visitor fills up the form on your website or you get any leads through your website, it will store the data on Highrise. It will also create a task and assign it to a user.

Highrise provides its API that helps to integrate Highrise with a WordPress website. We will use the same to develop a plugin that will enable  the following functionalities.

  1. Check if the contact with the given email ID exists on Highrise or not.
  2. If does not exist, it creates a contact on Highrise.
  3. Add a note from the message to the contact.
  4. Create a task for a particular note with the mentioned task category.
  5.  Assign the task to the mentioned CRM user.
  6. If any exception is generated by the API, it will send an email to the admin.

To integrate Highrise with WordPress site you will need its credentials:

1). Account Name

2). Highrise API token key

Getting Required Credentials Of Highrise CRM

1). Account Name

When you login to 37Signal’s Highrise CRM , it redirects to a page with a sub-domain. The ‘sub-domain’ here is your account name. For example, your link is:

Then your account name is ‘xyz’.

2). Highrise API Token Key

After logging into your Highrise CRM’s account, visit ‘My Profile’ under ‘Accounts & Settings’ . Under the tab API token you can find your key there.

Make sure you do not reveal the key to anyone, because with this key and account name, anyone can easily access your Highrise account. In case, the key is revealed to someone, you can regenerate it there.

Getting Started With Plugin Development for Integrating Highrise With WordPress

Before starting the tutorial you may like to get the whole source code for integrating Highrise with WordPress on GitHub.

To start coding open up your project in any of your favorite IDE. Go to ‘ Wp-Content’ and under that go to the folder ‘ Plugins’. Create a new folder with the name ‘ highrise-api’.

Now in the ‘ highrise-api’ create a file with the name ‘ index.php ’. This will act as your base file for the WordPress plugin to integrate Highrise with WordPress site. Copy paste the below given code in your index file.

 Plugin Name: Highrise API
 Plugin URI:
 Description: The plugin integrates the CRM highrise with the WordPress website. Whenever a form is submitted by the end user, the plugin will store the details in Highrise in the predefined format.
 Author: Regur Technology Solutions
 Version: 1.0
 Author URI:

This will make up a base for your plugin, which will show it in the plugin’s list in your WordPress admin panel.

Getting The Highrise Library For Your WordPress Plugin

Visit GitHub for Highrise PHP API and in the files stored there, go to ‘ lib’ folder. Under that open up the file HighriseAPI.class.php. You can click here to directly open up the HighriseAPI.class.php file.

Now go back to the IDE and create a new folder named ‘ lib ’ under the ‘ highrise-api’ folder that we created recently. Now download the file and save it in the ‘ lib’ folder. If you face difficulty in downloading the file, simply copy paste the whole content and paste it in a new file in the ‘ lib’ folder. Make sure that you name the new file similar to that of the file in GitHub i.e. HighriseAPI.class.php.

This will help us in integrating Highrise with WordPress to call all the methods to store and fetch data from Highrise.

Create Config File To Define Constants Used In Integrating Highrise With WordPress

There are a few constants that will be used throughout the code. So in case if you need to change them in future, you do not need to go changing all the variables throughout the code. Here, we will decalre constatnts like form Id, task owner in Highrise, time frame of each task, etc.

Create a file ‘highrise-api-config.php’ in the ‘highrise-api’ folder and paste the below given code:

Note: Make sure you change all the constant’s values to make it compatible with your site.

	define('ACCOUNT_NAME', 'xyz');			// Form ID should be similar to the form you have in your front end
	define('API_TOKEN', 'g126dv1df1vgfd2b546dfg12dgf');			// Form ID should be similar to the form you have in your front end
	define('FORM_ID', 'contact-us');			// Form ID should be similar to the form you have in your front end
	define('FROM_EMAIL', '');		// FROM EMAIL to send email in case any exception occurs
	define('TO_EMAIL', '');						// TO EMAIL to send email in case any exception occurs
	define('EMAIL_SUBJECT', 'IMP: Form Entry was not submitted to Highrise');		// EMAIL SUBJECT to send email in case any exception occurs
	define('TASK_CATEGORY_ID', '5959885');				//Category ID for Highrise. You can get this by inspecting the element of dropdown in task category list.
	define('TIME_FRAME', 'tomorrow');					//Time frame for each created task on highrise
	define('SUBJECT_NOTE', 'Party');					//Note Subject to be put up on Highrise
	define('OWNER_ID', '1152365');						//The CRM user to whom the tasks will be assigned. You can get it by inspecitn the dropdown element in the users list while creating a task

Configuring Highrise API.

Now, its time to link up your WordPress site with Highrise API. Create a ‘functions.php’ file in the ‘ highrise-api’ folder. Paste the below given code into the file.

//			Connect To Highrise

	function initiateApi()
			$highrise = new HighriseAPI();
			$highrise->setAccount( ACCOUNT_NAME );
			$highrise->setToken( API_TOKEN );
			$highrise->debug = false;	

		return $highrise; 

This will create a function to initiate the API integration every time we need.  Now go to index.php and include the ‘functions.php‘ and ‘highrise-api-config.php‘ file.

include "highrise-api-config.php";
include "functions.php";

Now, Its Time To Get In Action. Save Details On Highrise

Go to ‘ functions.php’ and paste the below-given code snippets:

Initializing Connection With Highrise API:

Here we will call the function ‘initiateApi that we defined earlier. This will give the necessary credentials to connect with the Highrise API. The ‘try’ block at the end of this code snippet is used to check whether an exception has occured or not.

//			Save Details On Highrise

	function saveDetailsOnHighrise()
		$highrise = initiateApi();
		if( $_POST['contact-form-id'] == FORM_ID )			//$_POST['contact-form-id'] will give the id of the form. Make sure you have such field in your contact form. If not make a hidden field.

Get Required Details To Store Data In Highrise

Here we will collect the data sent by the form. In this example, we have three fields namely name, email Id, and message (as a note). Also, we need few other constants to create a task on highrise like time frame, owner, etc.

				//Get required details  IMPORTANT: Change the field names according to your form.
				$name 			= $_POST['name'];				//Name of the contact
				$emailId 		= $_POST['email'];				//Email of the contact
				$noteBody 		= $_POST['message'];			//Message in the form to be stored as note in Highrise
				$taskCategoryId = TASK_CATEGORY_ID;				//Task Category ID
				$timeFrame 		= TIME_FRAME;					//Set the time frame for task generated at Highrise
				$noteSubject 	= SUBJECT_NOTE;					//Set the subject of each note
				$ownerId 		= OWNER_ID;				//To whom the task will be assigned

Check If A Contact Exists In Highrise

As per our description above, our code will first check if there exists a contact on Highrise with the same email Id that is entered in the form. If the contact exists, it will return the contact’s unique Id.

				// Get a persons' ID if person exists with the entered mailId.
				$personId = '';
				$people = $highrise->findPeopleByEmail($emailId);
				foreach($people as $person)
					$personId = $person->getId();

If A Contact Is Not Found On Highrise, Add It

Now, if the contact is not found on the highrise with the same email Id as that entered in the form, it will be created. We do this so that all the notes for the same person could be viewed at the same time in chronological order.

				//If no person found with the entered email ID add the person (Modify the fields according to the form)
				if( empty( $personId ) )
					$person = new HighrisePerson($highrise);
					$people = $highrise->findPeopleByEmail($emailId);
					foreach($people as $person)
						$personId = $person->getId();

Add A Note On Highrise With Your WordPress Plugin

Here, we are saving the message in the form as a note on Highrise. It will be saved under the contact / person that we created in the above code snippet.

				//Add Note
				$note = new HighriseNote($highrise);

Create A Task On Highrise

After adding a note to the contact, we will now add a task to follow up and assign it to the specified CRM user. This task can be viewed from the tasks list and from the contact’s detail as well.

				// Create a task
				$task = new HighriseTask($highrise);
				$task->setBody("Follow up with $name by Email");
			} //End try

Send An Email To The Admin If An Exception Is Thrown.

We started a ‘try‘ at the beginning of the code. If the Highrise API throws an exception it could be caught by ‘catch’ and it will be stored in $e as in the below code. If an exception occurs, the WordPress plugin will send an email to the admin, notifying about the exception.

                         catch (Exception $e){
				//Send an email to the admin, in case there is any exception generated by Highrise API.
				$body = "The data was not stored in Highrise. 
						Get the data for this entry from  WordPress admin panel. 
						Please verify the credentials and if the problem persists, contact site admin.<br>
						Name: $name<br>
						EmailId = $emailId<br>
				$body = nl2br($body);

Sending Custom Emails With A Custom WordPress Plugin

As the above code is sending an email when an exception is thrown, there is a function in the last line ‘sendEmail($body);‘ We need to define the function that will send an email using the ‘wp_email()’ function of WordPress.

        function sendEmail($body)
		$from 		= FROM_EMAIL;
		$to 		= TO_EMAIL;
		$subject 	= EMAIL_SUBJECT;
		if(empty($from) || empty($to) || empty($subject) || empty($body))
			return false;
		if(!(filter_var($to, FILTER_VALIDATE_EMAIL)))
			return false;		
		$headers = "MIME-Version: 1.0" . "\r\n";
		$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
		$headers .= "From: $from \r\n";

Hook The Function When Form Is Submitted

Here, in this example we have used the hook of JetPack forms. You need to use the hook that is compatible with your form. Paste the below given code in ‘index.php‘.

        function addContact()
	add_action('save_post_feedback', 'addContact');

Here, ‘save_post_feedback‘ is the hook of the JetPack form, you need to replace it with the hook of your form.

You can also find the complete source code for integrating Highrise with WordPress on GitHub.

This completes our WordPress custom Plugin to integrate Highrise with WordPress. Now, activate your plugin in the WordPress admin panel and Get, Set, Go..!

For more such posts follow us on Facebook. 🙂