ACF Update Field function doesn't work with woocommerce product - Stack Overflow

admin2025-04-29  1

Any help is appreciated Here's the code. Any idea what i'm doing wrong?

add_action('admin_post_ple_update_location', 'ple_update_location');
function ple_update_location() {
    if (!empty($_POST['product_id']) && !empty($_POST['new_location'])) {
        $product_id = intval($_POST['product_id']);
        $new_location = sanitize_text_field($_POST['new_location']);

        update_field('location', $new_location, $product_id); 

        wp_redirect(admin_url('admin.php?page=product-location-editor&updated=true'));
        exit;
    }
}

I'm trying to get an ACF field updated for a woocommerce product

转载请注明原文地址:http://anycun.com/QandA/1745937199a91367.html