Consultant data with JobRelay

Many websites want to show consultant data alongside the current job, usually with the name of the consultant who is responsible for the job advert and maybe contact details etc.

When a job gets delivered from the posting service via JobRelay, the following consultant data is delivered too:

In some instances, the values of these fields may not be the consultant details posting the job. This is to do with the way in which your organisation is setup in your posting provider. Please speak to them about the values that are being sent.

The values of these fields can be saved as post meta against the newly created job, when the job is sent from JobRelay. To make sure these values are saved, add the following to your meta mappings setting in the Settings > JobRelay Settings page in the WordPress admin area.


In the example above, the consultants email address can then be obtained in WordPress using the following code.

<?php echo esc_html( get_post_meta( $post->ID, '_contact_email', true ); ?>

The contact email address is the unique piece of information here.

Setting the job post author

By default, JobRelay tries to set a WordPress user as the author of each job that is delivered. WordPress takes the value sent in the contact_email field and tries to find a user with a matching email address.

If a user is found, this user is then assigned as the author of the job post in WordPress.

Storing consultant details in a post type

Often, sites want a specific post type for consultants or team members. This is often because this means each consultant with have a front end URL or permalink page.

If this is the case, you may want to store the post ID of the corresponding consultant when a new job is delivered from JobRelay.

The code below, added to either your themes functions.php file or better still a plugin with save the consultant post ID (if it exists) with a meta key of _consultant_post_id.

 * Saves the consultant post ID when a new job is posted.
 * @param integer $job_post_id The post ID of the newly created or updated job.
 * @param array   $job_data    An array of all the job data posted via JobRelay.
function hd_store_consultant_post_id( $job_post_id, $job_data ) {

	// if we don't have a consultant email address in the feed.
	if ( empty( $job_data['contact_email'] ) ) {

	// find a consultant post with the consultant email address sent in the feed.
	$consultants = get_posts(
			'post_type'      => 'hd_consultant', // change for the name of the consultant post type.
			'post_status'    => 'publish',
			'fields'         => 'ids',
			'posts_per_page' => 100, // if you have more than 100 consultants, increase this.
			'meta_query'     => [
					'key'     => '_consultant_email', // change for the meta key storing the consultant email.
					'value'   => sanitize_email( $job_data['contact_email'] ),

	// grab the last post returned - there should only be one.
	$consultant_id = array_pop( $consultants->posts );

	// if we have no consultant id.
	if ( empty( $consultant_id ) ) {

	// save the consultant id as meta data against the job.
	update_post_meta( $job_post_id, '_consultant_post_id', $consultant_id );


add_action( 'jobrelay_wpcon_job_inserted_complete', 'hd_store_consultant_post_id', 10, 3 );