It's all about timing. You have to learn what their "I'm about to take a crap" signs are, and then get them to the toilet at that magic moment. You do it too soon, and they won't go. You do it too late, and you missed your window.
My son would sort of shudder before he had to go. The hardest part was figuring out how long I had to get him to the toilet, but I was able to figure it out.
When they mess in their pants, they have to clean it up. My firstborn HATED that. He had to rinse it in the toilet and then change into clean clothes (by himself). It was pure torture and he eventually stopped.
On the other hand, my second born LOVED cleaning up the mess. He got excited about it. Grrrr. With him, he had to go naked after he soiled/wet his pants. I wasn't going to keep putting him in clean clothes. That solved it in just a few days.
Hmmmmm...... I have tried just about everything! I stopped using pull-ups, tried rewards, tried taking things away if he goes in his pants, make him clean himself and the underwear (He hates it but still goes in his pants) and I have hosed him off outside. Nothing has worked for me. When you find the secret, please let me know!
For my first I put a calendar in the bathroom and when he pooped in his pants I would set him on the potty to wipe his butt. That got him started associating poop with potty. If he allowed that with no trouble then I would also put a sticker on the calendar. Once that was well established I payed very close attention... the next time I noticed he was trying to poop I rushed him to the bathroom and he finished in the potty. He got a hotwheel for that one (any small prize would work though as long as it's something the child values) I made a big deal about how awesome it was and made sure he knew that the hotwheel was for pooping in the potty. Then after that I just reminded him regularly that if he went in the potty he got a cool prize. It didn't take long to phase out the prizes when it was done. Whatever route you take, don't embarrass, shame, or punish him for it. Good Luck.