Integrating BroadBean Job Posting with WordPress

Check out JobRelay, our new improved product for integrating WordPress with job posting and distribution software such as Broadbean, LogicMelon and Idibu. It is faster to integrate cheaper and uses a more modern approach.

banner-772x250

A few months ago one of our biggest clients came along with a request to integrate the BroadBean Job posting solution into their website. Of course I had built the recruitment website using WordPress in order to for them to post jobs to their site and enable them to recruit people to specific jobs etc. As part of the build it was important that as well as being able to post jobs to the site using the normal WordPress way (writing posts etc) they wanted to be able to use external sources to post to their site too, in this case Broadbean. Here is how I went about this with help from colleague David Hassen.

Let me outline first what Broadbean actually is and how it works. Recruitment companies need to get their job posts out to a wide variety of clients across the UK and beyond and therefore as well as posting jobs to their own website they need to tap into other job posting sites. This means a lot of repetition in terms of writing the advertisement on all of these sites. This is were the Broadbean system comes in. With it, you write one job listing and then Broadbean system sends this job to many of the jobs sites including your own website. It was the later which myself and colleagues needed to integrate into the clients WordPress site.

Broadbean provide you with either an XML feed or a they use the PHP Post method in order to send the completed job form to your site. Therefore we designate a URL to which this ‘feed’ is sent to and then at this URL we need some code to interoperate this feed and then add a post to our WordPress site including the information in the feed.

As we were using the post method the first stage of this was to get the value from the posted information and separate them, storing each as PHP variables. In the example below, we are assuming that there are 4 pieces of information that are sent. These are the job title, job category, job description and job type (part time or permanent etc.). To start with we grab the information and store it as variables like this:

[php]
$pj_jobTitle = $_POST[“job_title”];
$pj_jobCategory = $_POST[“job_category”];
$pj_jobDescription = $_POST[“job_description”];
$pj_jobType = $_POST[“job_type”];
[/php]

The variables names prefixed with ‘pj_’ are the names I have chosen to store the values in. Always prefix you variables names to avoid clashes in your system. In the square brackets above are the names of the values sent by Broadbean (they will ask you for these when you set up this system).

Now we have the information, we need to add this to our WordPress website, probably as a post. To do this we make use of the wp_insert_post() WordPress function. Before we get into that lets think about each piece of information and how we would add it to a WordPress post.

To start with the Job Title (we have this as the variable $pj_jobTitle) can be added as the title of the post. The job category will be added as a post category and the job description will be added as the post content. The job type will need to be added as a custom field (meta data) to the post once we have created the post. First lets create a new post using job title, job category and job description. This is where the wp_insert_post() comes into play and we do it like this:

[php]
// create post object
$pj_post = array(
‘post_title’ => $pj_jobTitle,
‘post_category’ => array($pj_jobCategory),
‘post_content’ => $pj_jobDescription,
‘post_author’ => ‘4’,
‘post_status’ => ‘publish’,
);
// adds the post and return the post id to this variable
$pj_jobpostid = wp_insert_post($pj_post);
[/php]

The first part here we simple create a variable that stores all of our post data as an array (all except our custom meta data – the job type). The second part using the wp_insert_post() adding our variable containing the post data to the function. The wp_insert_post() function, when successful returns the ID of the post that is created so we are going to store this ID (we will need it to add the meta data) in the variable $pj_jobpostid.

Now we can add the job type as a custom field. To do this we are going to use the add_post_meta() function. This adds a custom field to a post given the posts ID (in our case $pj_jobpostid) the custom field key (in this case pj_job_type) and the value you want for this custom field (in our case $pj_jobType. This is added using the following code:

[php]
if($pj_jobpostid != 0) {
add_post_meta($pj_jobpostid, ‘pj_job_type’, $pj_jobType, true);
}
[/php]

We wrap this code in an IF statement that basically says if the value of $pj_jobpostid is anything but 0 (i.e. the wp_insert_post() has worked) then add our custom field.

The final thing to do is to give the user and Broadbean some feedback in order to check whether the whole process has worked. To so this we can add to our IF statement above something like the following:

[php]
if($pj_jobpostid != 0) { // if adding job is successful
add_post_meta($pj_jobpostid, ‘pj_job_type’, $pj_jobType, true);
echo ‘Nice one! The job has been added.’;
} else { // if adding the job failed
echo ‘There has been an error adding the post to the database!’;
}
[/php]

So there we have it. A system that allows you to use Broadbean in order to add jobs to your WordPress website as posts.

12 responses

  1. Hi Mark, this seems like an elegant solution! I was wondering, how did you handle removal of posts (i.e. when a job is taken)? Were you able to create an automated process, or was manual removal required?

  2. Hi Robert,

    Our client never mentioned removing posts, it never came up as a requirement. I guess you could do something with wp_delete_post in order to remove it.

  3. Hi Mark,

    That’s a very interesting post!

    As a prospect asked me to integrate Broadbean into his future website and I am not familiar to the Broadbean tool yet, could you help me on these questions?
    – how do you indicate the page where you capture the POST-actions (just adding a “job board” in the tool => I read about it on their website)?
    – how do you indicate the fields that will be sent to the “capturing page”?
    – will the tool call the “capturing page” upon each creation in the tool, so WP posts are done automatically?
    – how candidates can respond to the vacancy? Did you mention a Broadbean link or did you create a mail upon their reaction on WP?

    Best Belgian regards,
    Jurgen

    1. @jurgen

      To answer your points:
      I created a page template and then created a WordPress page which was assigned this page template. This page template handled the capturing of the data sent by broadbean.

      The fields sent to the capturing page are set by broadbean – they will tell you what they need.

      Yes broad broadbean sends the data to the capturing page each time a new job is posted.

      Broadbean provided a unique email address for each job. All applications were sent to this unique email address for each application.

      Hope this helps.

      1. Hi Mark,

        Thanks for your quick reply!

        Seems interesting, I will try to handle this with the info from your post (or you can send me if you got some more ;o) ).

        How can candidates respond? By leaving a reply like I do right now? Or do you have to tweak some WordPress code to send the completed form upon saving? Or do they have to click the special mail adress and send a normal mail?

        1. Candidates reply or apply to the job postings by completing an online form which then sends a notification to the unique email address mentioned.

  4. Daniel Long Avatar
    Daniel Long

    Hi Mark,

    This is a very useful post and interesting read. It’s actually something I’m looking at doing in the near future.

    One question I have, if you could help me understand is, which ‘product’ did you get from Broadbean and did they charge you the £3995 I’ve seen on their website?

    Do you literally go onto the ‘Job Boards’ tab on the api.adcourier.com website, fill out the details there and they develop the feed from there, to post to the WordPress website?

    Any help would be hugely appreciated.

  5. Hello Mark,

    Hope you are doing well. I read your above post and I am also need help regarding boradbean integration. I have created the page template and a page in wordpress as you specified above. Could you please share what code you wrote to fetch the jobs from broadbean? If you could please share the sample code, that will be really great help.
    Thanks in advance for your support.

    Regards,
    Rajendra

    1. Why not take a look at my up and coming plugin on Github which may answer some of your questions in your look at the code.

      https://github.com/wpmark/wpbroadbean

  6. Karam Sihra Avatar
    Karam Sihra

    Hi Mark,

    Great article and work here. I have no experience with Broadbean and actually barely any experience integrating an API like Broadbean to a website but…

    The plugin that you have been working on that you listed. Would that cut out all the work that you are explaining in the above article and potentially work as a plug and play feature – fill in settings to make the connection and away you go with the Broadbean integration on WordPress?

    I’m looking at potentially re-doing a website for a big client of mine that I currently just do maintenance for but they need this feature on their new website and as I said it’s something I haven’t had experience in before.

    Regards,
    Karam Sihra

    1. Yes you are correct here in that the plugin takes care of the stuff in the article above. I would not say it is totally plug and play as we are integrating with a third party and therefore they need to be involved too.

      However it does cut down on some of the dev time that is needed as the plugin handles a lot of it for you. If you are going to give it a go I would wait a few weeks until version 2.0 comes out which has much better features and extensibility.

      https://markwilkinson.me/2014/12/wp-broadbean-v2-0-coming-soon/

  7. Is there a way of accessing a test/dummy API for Broadbean without paying for a Broadbean account?

Leave a Reply

Your email address will not be published. Required fields are marked *