1 ) The past perfect is often used when speaking of two things that occurred in the past, in order to mark that one thing happenned before the other.
example – When I arrived home, I realized that I’d lost my keys.
2) Background events – When narrating background events that happened prior to the current point in the story.
example – She had always been told not to speak to strangers…
3) The past perfect is often used to report speech when when the speaker has used present perfect or past simple tenses.
example – She said that she had just finished washing the car.
4) Superlative statements in the past –
example – It was the best meal I’d ever eaten.
*If the word “before” or “after” is used to indicate that a prior event happened at a specific time, the word “before” or “after” signals the order of events and therefore the past perfect is optional.
example 1 – Before I went to bed, I brushed my teeth. (correct)
example 2 – Before I went to bed, I had brushed my teeth. (correct)
…However if the earlier event was not at a defined time the past perfect is required.
example – Before I began my career in accounting, I had been through many training programs.