I have a button that when you click it, it triggers an ajax call to a function that should delete a row in a acf repeater field based on a data attribute.
Here's the function, but row in question doesn't delete:
add_action('wp_ajax_nopriv_remove_from_playlist','remove_from_playlist');
add_action( 'wp_ajax_remove_from_playlist', 'remove_from_playlist' );
function remove_from_playlist() {
$field_key = 'field_5b6b8c16eb66b';
$userID = $_POST['user'];
$lessonID = $_POST['lessonID'];
if( have_rows('user_playlist', $userID) ):
while( have_rows('user_playlist', $userID) ) : the_row();
$value = get_sub_field('post_id');
if($value === $lessonID) {
$row = get_row_index();
delete_row($field_key, $row, $userID);
}
endwhile;
endif;
die();
}