Created
November 24, 2022 16:04
-
-
Save propertyhive/63d964f6869db1bebd6e0ede26b41d38 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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