Use an if-statement before you apply the input value. Yeah, it's that simple. When you made the movement for your character, you also at some time had to set up a function tied to an input which applies the value of the input to the movement.
I guess your issue 1 year ago was finding it and you probably did find it by now, but for anyone else: It most certainly is inside your character's cpp/blueprint (Surprise)
My bad if there is some sort of standardized movement system which requires no set-up at all.
Also, you can use plane restrictions from your movement component to lock the character to certain axes.