Past perfect is used to talk about an action in the past, which happened before another action in the past.
When he had finished his homework, he went out.
He went out when he had finished his homework.
(Firs action: he finished his homework. Second action: he went out.)
When Sarah arrived at the party, Paul wasn't there. He had gone home.
The home was dirty. They hadn't cleaned it for weeks.
A woman walked into the room. She was a complete stranger to me. I hadn't seen her before.
The man sitting next to me on the plane was very nervous. He had never flown bebore.
By the time I got to the station, the train had left.
Student or Learner