Support

Account

Home Forums Front-end Issues ACF google map issue

Solving

ACF google map issue

  • I am using ACF google map in my site
    but I cant update the location from front end

    $field_name = ‘field_5c892edd8235d’;
    $value = array(‘address’=>$google_location[‘address’], ‘lat’=>$google_location[‘lat’], ‘lng’=>$google_location[‘lng’], ‘zoom’=>5);
    update_post_meta($property_id, ‘google_location’, $value);

    I did like this
    but it is not working
    What should I do?
    Please help me

  • If you want to update a field, use update_field( ‘NAME_OF_FIELD’, $VALUE, $PROPERTY_ID);

    documentation : https://www.advancedcustomfields.com/resources/update_field/

  • of course, I tried already like this

    $value = array(‘address’=>$google_location[‘address’], ‘lat’=>$google_location[‘lat’], ‘lng’=>$google_location[‘lng’], ‘zoom’=>5);
    update_field(‘google_location’, $value, $property_id);

    but it was not working

  • I don’t know the format of the array saved by ACF in the database. You’ll need to look at an existing one in the DB and make sure that you match it exactly.

    Assuming that your format is right, always use the field key to update the field if it may not already be set with something. Using update_post_meta() without manually adding the field key reference will not work. This ACF field type cannot work properly without the field key reference added to the database.

    
    $field_name = 'field_5c892edd8235d';
    $value = array('address'=>$google_location['address'], 'lat'=>$google_location['lat'], 'lng'=>$google_location['lng'], 'zoom'=>5);
    update_field($field_name, $value, $property_id);
    
Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘ACF google map issue’ is closed to new replies.