First af all if (null === $read_notices)
is never true
, because get_user_meta
return false or empty string or empty array. Never return null.
Right way is check if it is empty:
if ( empty ($read_notices) ) { ... }
Then your problem is that using get_user_meta
without passing the 3rd parameter as true
will return a multidimensional array.
So right code for you scope is:
$read_notices = get_user_meta($userID, $meta_key, true) ? : array();
$prev = $read_notices;
$read_notices[] = $postID;
update_user_meta($userID, $meta_key, $read_notices, $prev);