Depends what you mean by “worked”. It prevented the emergence of priest kings quite well. Not allowing legitimate sons puts a major crimp in anyone’s plans to turn a religious organization’s land into their personal property. See how the Teutonic order turned into Brandenburg upon Protestantisation.