Code snippets and customisations

Below are some popular code snippets that we have used for different clients for a variety of different reasons.

Forcing the value of a specific field

Sometimes you may want a value for a field to always be a specific value, rather than the value that is sent from the posting service.

The code below will allow you to do this – either add to your themes functions.php file or include as part of a plugin. In this example we use the company name field.

/**
 * Override a JobRelay field for all jobs.
 *
 * @param  array $job_data The array of job data sent from JobRelay.
 * @return array $job_data The modified job data array.
 */
function hd_overide_jobrelay_field( $job_data ) {

	// set the new value for the field - company name in this example
	$job_data['company_name'] = 'Highrise Digtial';

	// return the job data.
	return $job_data;

}

add_filter( 'jobrelay_wpcon_job_data', 'hd_overide_jobrelay_field', 10, 1 );

Check if a job has been delivered from JobRelay

Sometimes a website owner or developer, may want do something specific for JobRelay jobs only. To do this you can use the code below in your templates to check whether a job was delivered from JobRelay.

<?php
/**
 * Check if a job is delivered via JobRelay.
 *
 * All jobs that are delivered via JobRelay are assigned the "External" term in the jobrelay_source taxonomy.
 */
if ( has_term( 'External', 'jobrelay_source' )  ) {

	// do stuff here for external jobs only.

}