I know that i should use update_post_meta() function but don't know where put it in the code. I tried on the diferent ways but it's don't work how it should.
if ( ! function_exists( 'noo_render_location_picker_field' ) ) :
function noo_render_location_picker_field( $field = array(), $field_id = '', $value = '', $form_type = '', $object = array() ) {
wp_enqueue_script( 'location-picker' );
$post_id = ! empty( $object ) ? $object['ID'] : 0;
$input_id = $field_id;
$class = isset( $field['required'] ) && $field['required'] ? 'class="noo-mb-location-address form-control jform-validate" required aria-required="true"' : ' class="noo-mb-location-address form-control"';
$address = noo_get_post_meta( $post_id, $field_id, '' );
$lat = noo_get_post_meta( $post_id, $field_id . '_lat', '' );
$lon = noo_get_post_meta( $post_id, $field_id . '_lon', '' );
$is_frontend_submit = ( isset( $_GET['action'] ) && $_GET['action'] == 'post_job' ) ? true : false;
$is_edit_job = ( isset( $_GET['job_id'] ) && ! empty( $_GET['job_id'] ) ) ? true : false;
$checkbox_label = __( 'The same as company address', 'noo' );
$checkbox_id = '_use_company_address';
$company_id = jm_get_employer_company();
$full_address_company = ! empty( $company_id ) ? get_post_meta( $company_id, '_full_address', true ) : '';
$checkbox_value = empty( $post_id ) ? 1 : get_post_meta( $post_id, $checkbox_id, true );
if ( ($is_frontend_submit && !empty($full_address_company) ) or (!empty($full_address_company) && $is_edit_job)):
?>
<input name="<?php echo $checkbox_id; ?>" type="hidden" value="0"/>
<div class="form-control-flat">
<label class="checkbox">
<input id="use_company_address" name="<?php echo $checkbox_id; ?>" type="checkbox" <?php checked( $checkbox_value ); ?> value="1"/><i></i>
<?php echo esc_html( $checkbox_label ); ?>
</label>
</div>
<script>
jQuery(document).ready(function () {
jQuery("#use_company_address").change(function () {
if (jQuery(this).is(":checked")) {
jQuery(".noo-location-picker-field-wrap").addClass('hidden');
} else {
jQuery(".noo-location-picker-field-wrap").removeClass('hidden');
}
}).change();
});
</script>
<?php endif; ?>
<div class="noo-location-picker-field-wrap <?php echo $checkbox_value ? '' : ''; ?>">
<input <?php echo $class; ?> type="text" name="<?php echo esc_attr( $input_id ); ?>" value="<?php echo esc_html($address); ?>" placeholder="<?php echo esc_html__('Enter an exact address.', 'noo') ?>" />
<input type="hidden" class="noo-mb-lat" name="<?php echo esc_attr( $input_id ) ?>_lat" value="<?php echo $lat; ?>">
<input type="hidden" class="noo-mb-lon" name="<?php echo esc_attr( $input_id ) ?>_lon" value="<?php echo $lon; ?>">
<div class="noo-mb-job-location" id="<?php echo esc_attr( $input_id ); ?>" data-lat="<?php echo $lat; ?>"
data-lon="<?php echo $lon; ?>" style="height: 300px;">
</div>
</div>
<?php
}
endif;