Skip to content

Instantly share code, notes, and snippets.

@pbearne
Last active September 29, 2020 20:41
Show Gist options
  • Save pbearne/97b82f1265c5658dd021f5e05c74b884 to your computer and use it in GitHub Desktop.
Save pbearne/97b82f1265c5658dd021f5e05c74b884 to your computer and use it in GitHub Desktop.
function mdocs_example_matador_bullhorn_import_fields( $fields ) {
$field_to_add = [
'customText10' => [ // Name of field per Bullhorn Field Mappings (not its label)
'name' => 'customText10', // Set name for meta when 'saveas' is 'meta'.
'type' => 'string', // Specify type for sanitization, default 'type'
'saveas' => 'meta', // Options are 'core', 'meta', 'custom'. Default 'custom'
],
];
return array_merge( $fields, $field_to_add );
}
add_filter( 'matador_bullhorn_import_fields', 'mdocs_example_matador_bullhorn_import_fields' );
add_filter( 'matador_import_location_taxonomy_allowed_fields', function( $fields ) {
$fields[] = 'customText10';
return $fields;
});
add_filter( 'matador_import_location_taxonomy_field', function() {
return 'customText10';
});
global $m_country_list;
add_action( 'matador_import_after_save_job_location', function( $job, $wpid ) {
global $m_country_list;
if( isset( $job->customText10 ) ){
if( null === $m_country_list ){
$bullhorn = new matador\Bullhorn_Import();
$m_country_list = $bullhorn->get_countries();
}
if ( array_key_exists( $job->customText10 , $m_country_list ) ) {
update_post_meta($wpid, 'customText10', $m_country_list[ $job->customText10 ] );
}
}
return;
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment