In order to form the past perfect tense in German, you need the preterite form of to be/to have (sein/haben) and the second participle of the verb.

As usual, you take sein for verbs denoting a change of state or place, and haben everywhere else.

The preterite forms of to be/to have are the following:

sein haben
ich war ich hatte
du warst du hattest
er/sie/es war er/sie/es hatte
wir waren wir hatten
ihr wart ihr hattet
sie waren sie hatten
  •  The second participle for a weak verb is formed by prefixing ge- and suffixing –t to the verb, and for strong verbs you prefix ge- and suffix -en.
  • Note that many strong (and mixed) verbs change their stem in the second participle (e.g. gehen – gegangen).
  • If the stem ends in d/t, you suffix -et to the weak/mixed verb.
  • Do not prefix words with ge- if they end in –ieren, as in studieren – studiert.

You use the past perfect tense for actions before a certain moment in the past. Basically, like in English. I went to the doctor’s because I had been ill for weeks. Ich ging zum Arzt weil ich seit Wochen krank gewesen war.