apply_filters( ‘jobrelay_wpcon_job_data‘, $job_data array )

In this article

Filters the job data sent from the posting provider before it is processed.

Parameters

More information

This is good filter to use if you want to manipulate the data sent from the posting provider before any actions are taken in the WordPress site.

Example usage

Force a specific field value

Force a specific field value

In this example we force the value of the company name field.

Recruiters often do not want the company name of the company they are hiring for to appear in the company name, or hiring organisation on their WordPress jobs. As a result this field is often left blank in the feed of data to your site.

This can cause issues where the Hiring Organisation name is left blank in structured job data, used by Google to index jobs.

If this is the case we would recommend populating the company name for all your jobs with your own company name.

You can easily do this by filtering the job data that arrives to your website from JobRelay and forcing a specific company name.

<?php
/**
 * Overide the company logo 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 jobrelay_overide_company_name( $job_data ) {

	// set the company logo field.
	$job_data['company_name'] = 'Highrise Digtial'; // replace with actual company name.

	// return the job data.
	return $job_data;

}

add_filter( 'jobrelay_wpcon_job_data', 'jobrelay_overide_company_name', 10, 1 );
Combine JobRelay fields before saving

Combine JobRelay fields before saving

There may be times when you want to combine two or more fields before they are saved.

This allows you to save more than one JobRelay field against the same WordPress meta key or taxonomy term.

A good example of this is for salary. Salary is delivered in a number of fields, specifically a from and to value like so:

  • salary_from
  • salary_to

It is often the case that the salary display on the front end of your site should show the from and to values together. Of course you could write code to pull both values together with the output, but you could also combine them and save them together as well.

Below is some sample PHP which you could add to your themes functions.php file or as a plugin to combine the salary_from and salary_to values together, before saving them as a new custom field, with the key salary_from_to_combined (you could change this key to whatever you like of course!)

<?php
/**
 * Combine salary from and to fields into a single field.
 *
 * @param array $job_data The job data.
 * @return array The modified job data.
 */
function hd_combine_salary_fields( $job_data ) {

	// check we have a salary from and to field, doing nothing if not present.
	if ( ! isset( $job_data['salary_from'] ) || ! isset( $job_data['salary_to'] ) ) {
		return $job_data;
	}

	// create a new field in the incoming job data for salary from to.
	$job_data['salary_from_to'] = $job_data['salary_from'] . ' - ' . $job_data['salary_to'];

	// return the modified job data.
	return $job_data;

}

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

With this code in place, the incoming data will now have a new field with the key of salary_from_to and the value being a combination of the salary_from and salary_to field, separated with a hyphen.

The final step is to create a meta mapping in your JobRelay Settings page to save this incoming data to a custom field.

You could add something like this to your meta mappings which will save the value of the salary_from_to field to a custom field with the meta key of salary_from_to_combined.

"salary_from_to_combined":"salary_from_to"