We had issues with peeing at age 4 with both our oldest bio kid and our adopted kiddo. They did it out of anger/frustration. It was....odd, but I when I dared to share this info, we found out that "rage peeing" was not all THAT uncommon for boys around that age. Both boys outgrew it pretty quickly. Our youngest (bio) pooped in the yard, but that was mostly confusion. He thought if he could pee by the tree, he could poop there too. I don't know if the older 2 boys ever did that. I think they probably did and just never told on each other!
Our oldest bio kid is very smart but has some hard-wired behavioral challenges. Our adopted kiddo's only real trauma was coming to live with us, but that was a big one since he had lived with his foster family from 3 days to 11 months old, and then was suddenly with strangers (us).
If your friend has resources, I guess the thing for them to guide her on finding out what the boys feelings are when he does this. Is he confused? Is he angry? Is he trying to exert some control over his environment with this behavior? (all of these were true for us). For a foster kid, I'd also want to find out if the bathroom was a safe place prior to this. I wish your friend luck & yes, you may share may story if you think it will help.
-e