Using JobRelay with the WP Job Manager Geo search plugin

If you are using the WP Job Manager Geo search add-on, be sure to use the code below in order to ensure that each job has its location saved correctly when a job is delivered from JobRelay.

<?php
/*
Plugin Name: JobRelay Geo Search Compatibility
Plugin URI: https://highrise.digital/
Description: Allows JobRelay to work with the Geo search plugin..
Version: 1.0
License: GPL-2.0+
Author: Highrise Digital Ltd
Author URI: https://highrise.digital/
Text domain: jobrelay-geosearch-compatibility
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

/**
 * Updates the location data for a job in geo plugin when sent from JobRelay.
 *
 * @param  integer $job_post_id The newly created jobs post id.
 * @param  array   $job_data    The array of job data posted.
 */
function hd_geo_import_job_location_data_for_jobrelay( $job_post_id, $job_data ) {

	if ( function_exists( 'gjm_update_location' ) ) {

		// when a job is posted from JobRelay, update the job location data for the geo plugin.
		gjm_update_location(
			$job_post_id,
			array(
				'title'   => sanitize_text_field( $job_data['job_title'] ),
				'address' => sanitize_text_field( $job_data['job_location'] ),
				'email'   => sanitize_text_field( $job_data['application_email'] ),
			) 
		);

	}

}

add_action( 'jobrelay_wpcon_job_inserted_complete', 'hd_geo_import_job_location_data_for_jobrelay', 10, 2 );