Skip to content

Instantly share code, notes, and snippets.

@propertyhive
Created November 24, 2022 16:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save propertyhive/63d964f6869db1bebd6e0ede26b41d38 to your computer and use it in GitHub Desktop.
Save propertyhive/63d964f6869db1bebd6e0ede26b41d38 to your computer and use it in GitHub Desktop.
add_action( "propertyhive_property_imported_vaultea_json", 'import_custom_fields', 10, 2 );
function import_custom_fields( $post_id, $property )
{
$three_year_residency = '';
$cat_2_not_applicable = '';
$hepps_not_applicable = '';
if ( isset($property['custom']) && !empty($property['custom']) )
{
foreach ( $property['custom'] as $custom )
{
foreach ( $custom['fields'] as $field )
{
if ( $field['name'] == '3 Year Residency' )
{
$three_year_residency = ( $field['data'] == 'true' ) ? 'Yes' : (( $field['data'] == 'false' ) ? 'No' : '');
}
if ( $field['name'] == 'CAT 2 (Not Applicable)' )
{
$cat_2_not_applicable = ( $field['data'] == 'true' ) ? 'Yes' : (( $field['data'] == 'false' ) ? 'No' : '');
}
if ( $field['name'] == 'Hepps (Not Applicable)' )
{
$hepps_not_applicable = ( $field['data'] == 'true' ) ? 'Yes' : (( $field['data'] == 'false' ) ? 'No' : '');
}
}
}
}
update_post_meta( $post_id, '_3_year_residency', $three_year_residency );
update_post_meta( $post_id, '_cat_2_not_applicable', $cat_2_not_applicable );
update_post_meta( $post_id, '_hepps_not_applicable', $hepps_not_applicable );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment