【发布时间】:2019-03-19 05:24:25
【问题描述】:
我有一个按钮,当您单击它时,它会触发对函数的 ajax 调用,该函数应根据数据属性删除 acf 转发器字段中的一行。
这是函数,但有问题的行不会删除:
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();
}
【问题讨论】:
标签: wordpress advanced-custom-fields