First off, you can develop food allergies and sensitivities at ANY time, for adults it's under stress, for children the allergies can just arrive with development.
Something is irritating his bowels, obviously. Did he have ANY mucous before the constipation started? Were the first few impacted BMovements free of mucous or with it? I ask b/c it may show whether or not the irritated bowel is causing the impaction or vice versa.
Second, try some daily measures to get the BM out of your child. We can set up a pattern of Impaction/Evacuation and there are a few things we always think are going to help but often make it worse.
An irritated, impacted bowel should NOT have too much fiber bulk added to it. Our healthy instincts tell us to add things like whole grains, seeds, high fiber foods. Try instead flax seed oil, probiotics that are designed for intestinal health (I like Intestinal DF, but when my son was tiny we used Jarro-Dopholis), and PEAR JUICE!! If you're not already using a good, 100% pear juice (not the Gerber ones, try Knudsen or Nana Mae's, they have the good syrupy natural stuff that greases up those intestines), start using once a day, 4-6 oz. If that doesn't do it, try it twice a day. The only juice you should be giving him is pear juice, prune (tho I personally don't htink it works as well, plus my DS hates it), or apricot nectar. Each kid will react differently. Again, look for 100% apricot nectar, not apricot JUICE. These juices have sugars in them that actually absorb water to help them through the digestive tract. Unlike fiberous foods, the juices already have the water in them, whereas whole grains take the water from his system.
Once you've got this cycle of impaction/evacuation cleared up, I'd get your child tested for food allergies and parasites both. If you want to go western medicine, make sure to ask for a complete BLOOD work up for food allergies, including teh anti-gliadin (gluten) antibodies. If you want to go more Eastern medicine, people think that's great too. I haven't tried it.
I had the most constipated boy in teh world, my pediatrician is so good at not prescribing medicine, she told me the pear juice trick and it has SAVED us. Now my son has pear juice once a day and also a few ounces of OJ diluted. Other than that he just drinks water.
And, most importantly, make sure he's sipping water alllll the time.
I'm like the impacted poo expert. How weird. Oh, and put some nice KY jelly on his bottom when you think he's going ot have a BM. It will help him a lot.
I'm sorry this happened to you. Once you get the impaction cleared up, then it's time to watch for the behavioral changes. Being constipated will cause some major behavioral problems. Don't worry too much yet. COnstipation makes them hold back from pooing, so once he has a few painless ones, he'll be less likely to hold back, and that will break that cycle.