An ad hominem fallacy attacks the person making an argument rather than the argument itself. 'You're only saying that because you're rich,' 'she has no credentials,' 'look at his history' — none of these engage the claim. A dishonest person can state a true fact; a hypocrite can make a valid argument. The argument's merit is independent of who's holding it.
The subtlety worth learning is when it isn't a fallacy. If someone is offering testimony rather than an argument — 'trust me, the data says so' — then their credibility, expertise, and conflicts of interest are directly relevant, because you're being asked to rely on them personally. The distinction: attacking the source is legitimate when the source is the evidence, and fallacious when actual reasoning has been presented that you could evaluate on its own. The related trap is tu quoque ('you do it too') — a hypocrite's inconsistency says nothing about whether their claim is correct.