Have you had all of your vitamin levels checked? Many vitamin deficiencies can cause constipation. I was severely constipated for several months when I had never had any issues before...in fact I always had the opposite issue. After checking my levels it turned out I was B12 deficient. Since starting treatment I am back to normal. Hope you find something...
I forgot to mention to check with your doctor if you are on any other meds or if you have kidney issues for the extra magnesium. My husband also had issues with constipation for years and swears by it now.
Nuts, lots of veggies, and taking a daily magnesium (500mg) seems to work for me. Also, I excercise quite a bit and I notice when I don't I start to have issues.