Currently you can not unset key because you can not find proper key from array. The issue is that you did $stamp = array($_POST['stamp']);
as array which is wrong. you have to remove array()
from $stamp
, so which look like $stamp = $_POST['stamp'];
. then you can search value in column from array and unset it. I have tested below code which is working properly.
add_action( 'wp_ajax_dna_nuke_diary_slots', 'dna_nuke_diary_slots' );
function dna_nuke_diary_slots() {
$user = $_POST['user'];
$stamp = $_POST['stamp']; // here you have to remove array();
// values for these two variables are retrieved from custom data attribute in following html and ajax call
$stamps = !empty(get_user_meta( $user, 'dna_cal', true)) ? get_user_meta( $user, 'dna_cal', true) : array();
$key = array_search($stamp, array_column($stamps, 'dna_cal_when'));
unset($stamps[$key]);
$new_stamps = $stamps;
$sort_stamps = array_values($new_stamps);
update_user_meta( $user, 'dna_cal', $sort_stamps);
wp_die();
}