Ok, so motor shaft is M12 thread also and screws into flanged shaft? if that is the case then have the end of the flanged shaft castellated like on the end of a car wheel shaft. make sure the castellations are deep enough so as not to cover any of the motor shaft hole. You can then screw the flanged unit onto the motor shaft get it tightly home and press ? gently knock the roll pin through the castellations and motor shaft. this will stop the flanged unit from unscrewing. If you want belt and braces a little loctite doesn't hurt. If unsure google castellated nuts.