Q. Does God forgive us only on the condition that we forgive others ?
A. I take it you’re referring to Matt. 6:15, which says, “But if you do not forgive men their sins, your Father will not forgive your sins.” This verse comes at the end of the Lord’s prayer. It can only be prayed by believers, people who are already saved. We know this because the prayer begins with “Our Father in heaven.”
Therefore, the Lord couldn’t have been speaking of the forgiveness that brings salvation. He had to be speaking of the willingness to forgive others that keeps us in good standing (fellowship) with Him.
Our failure to forgive others is a sin, and God cannot forgive that sin until we forgive those who have wronged us. This cannot endanger our salvation but could deprive us of blessings we might have otherwise received. My study on The parable of the unmerciful servant (Matt. 18:21-35) gives a more complete explanation of this. Here’s a link.