When this happened to my son, we would give him as many raisins as he would tolerate, pear juice and/or prune juice, and add about a teaspoon of Benefiber (green bottle of powder you can find at drugstores, target or possibly even grocery stores)a few times of day to his drinks.
Eliminate any dairy, bread or constipating types of foods and only give him fiber-rich foods until he is relieved. Is he getting a good amount of fiber-rich foods on a regular basis? Could he possibly be having too much cheese/milk/white bread products? Maybe he needs more fruits/veggies in his regular diet? Could he be dehydrated and regularly need to sip on more water?
To reduce my son's fear of trying because he was afraid it would hurt, I told him that the juice and water/raisins, etc. made his poop softer so it would not hurt any more. The more water he drinks, the easier it will be to poop. He seemed to "get" this concept.
Good luck! I know this can be so difficult but my son got past it - I hope yours does soon! Take care.