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