This is actually a duplicated topic. I’ve answered him here: How to Add and Remove a Flag for a Post.