A step further back
The Plusquamperfekt puts an event before another past event. You are already telling a story in the past and need to reach behind it. English does this with had plus a participle, German with hatte or war plus a participle.
Two events, in order
Ich hatte schon gegessen, als sie kam.
I had already eaten when she arrived.
Eating first, arriving second.
Der Zug war schon abgefahren.
The train had already left.
abfahren takes sein, so the auxiliary is war.
Other persons
Wir hatten die Tickets zum Glück vorher gekauft.
Luckily we had bought the tickets beforehand.
Du hattest mir das nie erzählt.
You had never told me that.
Er hatte den Brief noch nicht gelesen.
He hadn't read the letter yet.
When you need it
The Plusquamperfekt only makes sense next to a second, later past event, in the same sentence or the one before. For a single past event use the Perfekt or Präteritum.
Order of events
The earlier event gets the Plusquamperfekt. The conjunction nachdem is the classic partner.
Nachdem er gegessen hatte, ging er spazieren.
After he had eaten, he went for a walk.
Als ich ankam, waren die anderen schon gegangen.
When I arrived, the others had already left.
Reason in the background
The reason lies further back than the state it explains.
Er war nervös, weil er nichts gegessen hatte.
He was nervous because he hadn't eaten anything.
Das Restaurant war voll. Wir hatten leider nicht reserviert.
The restaurant was full. Unfortunately we hadn't booked.
Flashback in a story
A story in the Präteritum steps back for a moment.
Sie kannte das Haus. Sie hatte dort als Kind gewohnt.
She knew the house. She had lived there as a child.
In conversation, schon or vorher with the Perfekt often does the same job: Ich habe vorher schon gegessen. The Plusquamperfekt is more typical of writing.
Word order in a subordinate clause
In a main clause the pieces sit where they do in the Perfekt: Er hatte den Zug verpasst. In a subordinate clause the conjugated auxiliary goes absolutely last, after the participle: …, weil er den Zug verpasst hatte. English keeps had in front of the participle, so this order feels inside out at first.
Sie war müde, weil sie schlecht geschlafen hatte.
She was tired because she had slept badly.
Er sagte, dass er den Termin vergessen hatte.
He said he had forgotten the appointment.
Nachdem der Regen aufgehört hatte, wurde es sofort wärmer.
After the rain had stopped, it immediately got warmer.