• chaosad2

    (@chaosad2)


    Hi,
    I wrote a short code added in functions.php.
    I updates ACF fields when custom posts are saved.
    It works fine when posts are added from backend admin.
    But it doesn’t seems to work when post is added from frontend.

    It looks like this :

    add_action( 'acf/save_post', 'update_acf_field_value');
    require_once('LOADING MY PHP FILE');
    
    function update_acf_field_value(){
    
    $url = get_field('LOAD A GPX FILE, $post->ID)['url'];
    $gpxStr = file_get_contents($url);
    $r = parseGpx($gpxStr);
    
    $lenght = $r->distance;

    update_field(‘distance’,$lenght2);
    }

    Should I modify/add something to extend this capability to frontend form ?
    Thanks !

  • The topic ‘Update datas when form is saved’ is closed to new replies.