Problem "Cannot modify header information" Ajax pluggable.php
Hi All
During registration of the user, I want to save its coordinates (latitude and longitude) in the database via the address entered. To do this, I use the Google Map API and AJAX for the record in the database.
The record in the database is done correctly.
Normally, after registration, the user should be redirected to the home page and be connected.
But I have these error messages :
Warning: Cannot modify header information - headers already sent by (output started at /home/horseevo/public_html/
wp-content/themes/classipress-labzip/functions.php:820) in /home/horseevo/public_html/
wp-includes/pluggable.php on line 584
Warning: Cannot modify header information - headers already sent by (output started at /home/horseevo/public_html/
wp-content/themes/classipress-labzip/functions.php:820) in /home/horseevo/public_html/
wp-includes/pluggable.php on line 585
Warning: Cannot modify header information - headers already sent by (output started at /home/horseevo/public_html/
wp-content/themes/classipress-labzip/functions.php:820) in /home/horseevo/public_html/
wp-includes/pluggable.php on line 586
Warning: Cannot modify header information - headers already sent by (output started at /home/horseevo/public_html/
wp-content/themes/classipress-labzip/functions.php:820) in /home/horseevo/public_html/
wp-includes/pluggable.php on line 748
Here is my code :
In the function.php in the child theme lapzip :
Code:
<script type='text/javascript'>
var address = '$adresse';
geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var latitude_adresse = results[0].geometry.location.lat();
var longitude_adresse = results[0].geometry.location.lng();
$(document).ready(function() {
$(function(){
$.ajax({
type: 'POST',
data: {'user_id':$user_id,'user_lat':latitude_adresse,'user_lng':longitude_adresse},
url: 'http://horse-evolu.com/wp-content/themes/classipress-labzip/update_profile_latlng.php'
});
});
});
}
});
</script>
update_profile_latlng.php :
Code:
<?php
$path = $_SERVER['DOCUMENT_ROOT'];
include_once $path . '/wp-config.php';
include_once $path . '/wp-load.php';
include_once $path . '/wp-includes/wp-db.php';
include_once $path . '/wp-includes/pluggable.php';
global $wpdb;
global $current_user;
$user_id = $_POST['user_id'] ;
$wpdb->update('wp_users', array("user_lat" => $_POST['user_lat']),array('ID' => $_POST['user_id']));
$wpdb->update('wp_users', array("user_lng" => $_POST['user_lng']),array('ID' => $_POST['user_id']));
?>
I tried several solutions found on the net (on pluggable.php)
- Addition of "?>" At the end of the file.
- Remove empty lines at the beginning and end of file.
- Remove empty lines in all the file.
I'm getting out of ideas
Thank you for your help