• Hello peeps of wordpress.
    I’ve encountered an issue with update_post_meta, which will be explained below.
    I have an array inside of a post called ‘client_notes’
    which is an array that consists of 4 fields.
    (meaning there’s a Key above those 4 fields)
    Yet, when I try and launch an unset for the key (using POST meta)
    it doesn’t delete it out of the database, whenever I click another note a different one deletes (wth?)
    So I chose to use “update_post_meta” instead,
    creating another array without the deleted notes,
    and overwriting the other one with it, yet, that doesn’t work T_T.
    my piece of code:

    if(isset($_POST['delete_client_note']))
    	{ 	$note_to_delete = $_POST['delete_client_note'];
    
    		foreach($messages as $key => $message){
    			if(($message==$note_to_delete) || ($message==(++$note_to_delete)))
    				continue;
    			else
    			{
    				$new_messages[$delete_array_index]['date'] = $message['date'];
    				$new_messages[$delete_array_index]['message'] = $message['message'];
    				$new_messages[$delete_array_index]['by'] = $message['by'];
    				$new_messages[$delete_array_index]['author'] = $message['author'];
    				$delete_array_index = $delete_array_index + 1;
    			}
    		}
    
    		update_post_meta($post_id, 'client_notes', $new_messages);
    	}

    any insight?

  • The topic ‘update post meta doesn't fire’ is closed to new replies.