Is there a way to disable the barometer?

Hello, I am using a cube black and I have a rtk system with good precision and I want to only use the data from this system for the altitude.

I tried using EK3_SRC1_POSZ to gps, and the others to none, and also tried setting the three sources to gps while setting EK3_AFFINITY to gps, but even so the barometer still has influence over altitude.

Is there a way to disable it?

Check this out.

just a question, for that I would need to download the whole arducopter, modify the code and then upload? is there a way to modify the code inside my autopilot?

Nope. You need to clone the git repository, install the cross-compiler toolchain, change the code, compile it and upload.