Context. Cosmic rays play an important role in dense molecular cores, affecting their thermal and dynamical evolution and initiating the chemistry. Several studies have shown that the formation of protostellar discs in collapsing clouds is severely hampered by the braking torque exerted by the entrained magnetic field on the infalling gas, as long as the field remains frozen to the gas. Aims. In this paper we examine the possibility that the concentration and twisting of the field lines in the inner region of collapse can produce a significant reduction of the ionisation fraction. Methods. To check whether the cosmic-ray ionisation rate can fall below the critical value required to maintain good coupling, we first study the propagation of cosmic rays in a model of a static magnetised cloud varying the relative strength of the toroidal/poloidal components and the mass-to-flux ratio. We then follow the path of cosmic rays using realistic magnetic field configurations generated by numerical simulations of a rotating collapsing core with different initial conditions. Results. We find that an increment of the toroidal component of the magnetic field, or, in general, a more twisted configuration of the field lines, results in a decrease in the cosmic-ray flux. This is mainly due to the magnetic mirroring effect that is stronger where larger variations in the field direction are present. In particular, we find a decrease of the cosmic-ray ionisation rate below 10 −18 s −1 in the central 300-400 AU, where density is higher than about 10 9 cm −3 . This very low value of the ionisation rate is attained in the cases of intermediate and low magnetisation (mass-to-flux ratio λ = 5 and 17, respectively) and for toroidal fields larger than about 40% of the total field. Conclusions. Magnetic field effects can significantly reduce the ionisation fraction in collapsing clouds. We provide a handy fitting formula to compute approximately the attenuation of the cosmic-ray ionisation rate in a molecular cloud as a function of the density and the magnetic configuration.