"When all men doubt you," you need to "trust yourself." The poet asks you to be confident and brave enough to face criticism and disapproval from others. Not always will others' opinion about you and situations be favorable to you. There would be times when your actions and intentions may be questioned and doubted. At those times, the poet advises you not to lose faith in yourself; instead you should still be upbeat and confident without getting distracted or disappointed by your unpopularity.
At the same time, the poet warns against being snobbish and condescending. Even if you’re confident, you must consider the criticism. The opposing ideas coming from others may hold some merit. By considering them, you may improve yourself further. Besides, this would project your personality to be modest and humble. This is what the poet means by the line “But make allowance for their doubting too.”
So, what we see is that, on the one hand, the poet advises you not to lose confidence when others doubt you, on the other, the poet asks you to consider the objection and disapproval seriously. This is quite paradoxical. Actually, the poet is asking you to strike a balance between being self-confident and being supercilious.
This implies that you shouldn't be dispirited against criticism, nevertheless, you should try to find merit in the points of objection. In fact, the whole poem “If” teaches one to strike a balance in life.