I'm going to give numbers to these sentences for reference.
(1) I'd barely said my name before he slapped me.
(2) I'd barely said my name before he has slapped me.
(3) I'd barely said my name before he had slapped me.
(4) I'd barely said my name when he slapped me.
(5) I'd barely said my name when he has slapped me.
(6) I'd barely said my name when he had slapped me.
Sentences (2), (5) and (6) are impossible, and there is little if any difference in meaning between (1), (3) and (4). The reason the past perfect is possible with before is that (3) brings to mind something like the creation of a new state in which he had already slapped you. Perhaps (3) evokes even more strongly than (1) and (4) the instantaneous nature of his action, as we do not, literally speaking, mention his action occurring but instead the state in which the action had already occurred.
Incidentally, one would say "replacing before with when" "changing before to when," or, perhaps less commonly, "changing before for when."
I agree with your comment. Consider:
(7) I had barely said my name before he led me to the interview room.
(8) I had barely said my name before he had led me to the interview room.
The difference here is a bit more perceptible than between (1) and (3). Sentence (8) clearly refers to the end of the process of leading you to the interview room, whereas (7) refers to the process as a whole, and the time of the "leading" action is most likely to be interpreted as the beginning of the process.