We usually use when with reference to the simple past tense because it refers to a point of time rather than a period of time.
When I reached the station, the train had left.
But can I say
When porter had opened the door, we entered.
Are the following two sentences grammatical
The porter had opened the gate and we entered.
The porter opened the gate and we entered.
Is it a rule, that when we use conjunction and both the clauses must be be in the same form?