Picture
Minnur Yunusov Senior Drupal Developer Follow
September 15, 2015

Recently I had an opportunity to integrate Drupal and the Greenhouse Job Board API for one of our clients. This was a very interesting and challenging task.

The main requirement for the integration was the ability to display and filter job locations and teams/departments as well as the ability to display custom job application forms.

I used several contributed modules and created a PHP library to achieve this:

Then I created custom CTools plugins for each display such as job location page, team page and the job details page. I added those plugins to pages via Page manager and added custom page layouts via Panels module.

Create a custom application form was the next step. The easiest way to add application form to job postings is to use Greenhouse's default HTML embed code that would display the form in the iframe, however this won't give much options to style the form.

To create a custom form I had only one option - make an API call to pull a job post with a parameter to return all questions and EEOC fields.

The call returns a list of fields that include the following:

  • Field name
  • Is field required
  • Field type
  • Field description

The field types are:

  • input_file - represent with an input of type file
  • input_text - represent with an input of type text
  • textarea - represent with a textarea
  • multi_value_single_select - can be represented as either a set of radio buttons or a select
  • multi_value_multi_select - can be represented as either a set of checkboxes or a multi-select

Based on that information I was able to use Drupal's Form API to build a custom form. The tricky part is that the API doesn't have a method programmatically authenticate a request (normally this is done in headers or some token such as OAuth generated token). Instead the request has to be proxied in order to hide credentials from the request.

I had to use Drupal's form submit handler to rebuild the request and create my own POST request against Greenhouse API to submit the application. It took me some time to implement ability to submit files. Luckily I recently build another PHP class that was using PHP Curl Class to make HTTP multipart requests. I reused the code and added it to the Greenhouse Job Board API integration PHP library.

Quick Start and Examples


require '../vendor/autoload.php';
require '../src/GreenhouseJobBoardAPI.php';

use \GreenhouseJobBoardAPI\GreenhouseJobBoardAPI;

$api_url = "https://api.greenhouse.io/v1/boards/{{CLIENT_CODE}}/embed/";
$greenhouse = new GreenhouseJobBoardAPI($api_url);

GET Methods

The method returns a list of all of your organization's departments and jobs, grouped by office.

$offices = $greenhouse->getOffices();

The method returns a list of your organization's departments and jobs for the given [OFFICE_ID].

$office = $greenhouse->getOffice([OFFICE_ID]);

The method returns a list of your organization's departments and jobs.

$departments = $greenhouse->getDepartments();

The method returns a list of jobs for a given [DEPARTMENT_ID].

$department = $greenhouse->getDepartment([DEPARTMENT_ID]);

The method returns the list of all jobs, with or without description.

$jobs = $greenhouse->getJobs(true);

The method returns a single job corresponding to the given [JOB_ID]. Setting second parameter to true will include the list of job application fields [optional]

$job = $greenhouse->getJob([JOB_ID], true);

The board method returns your organization's name and job board content.

$board = $greenhouse->getBoard();

You can find working examples in examples/example.php.

POST Job Application

Custom application form example can be found in the repo: examples/application.php.

Hopefully this will give you some glue on how you could integrate Greenhouse Job Boards on your website.

See on GitHub

Please post your questions in the comments below.

The Greenhouse is an applicant tracking system and recruiting software designed to help you find better candidates and improve your entire recruiting process.