add_action( "propertyhive_property_imported_vebra_api_xml", 'import_energy_stuff', 10, 2 ); function import_energy_stuff( $post_id, $property ) { if ( isset($property->hip->energy_performance->energy_efficiency->current) && (string)$property->hip->energy_performance->energy_efficiency->current != '' && (string)$property->hip->energy_performance->energy_efficiency->current != '0' ) { update_post_meta( $post_id, '_energy_efficiency_current', (string)$property->hip->energy_performance->energy_efficiency->current ); } if ( isset($property->hip->energy_performance->energy_efficiency->potential) && (string)$property->hip->energy_performance->energy_efficiency->potential != '' && (string)$property->hip->energy_performance->energy_efficiency->potential != '0' ) { update_post_meta( $post_id, '_energy_efficiency_potential', (string)$property->hip->energy_performance->energy_efficiency->potential ); } } add_action( "propertyhive_wpresidence_property_synced", 'sync_epc_stuff_to_wpr', 10, 3 ); function sync_epc_stuff_to_wpr( $ph_post_id, $wpr_post_id, $synced ) { if ( $synced === true ) { if ( get_post_meta( $ph_post_id, '_energy_efficiency_current', true ) != '' ) { update_post_meta( $wpr_post_id, 'epc_current_rating', get_post_meta( $ph_post_id, '_energy_efficiency_current', true ) ); } if ( get_post_meta( $ph_post_id, '_energy_efficiency_current', true ) != '' ) { update_post_meta( $wpr_post_id, 'epc_potential_rating', get_post_meta( $ph_post_id, '_energy_efficiency_potential', true ) ); } } }