My view: She's 3. Because she's 3, she's not capable of determining who a 'stranger' is and who isn't. The term 'stranger danger' is pretty meaningless at any age, but particularly with a 3 year old. 3 year olds need their parents to keep them safe.
Â
What you can do is explain to her that it's important that she stay with you because it's your job to keep her safe. That removes the burden from her shoulders. The easiest way to do this is to tell her that she needs to be able to see you at all times when you're out. (She has no idea if you can see her, but she'll be able to tell if she can see you.) If she can see you, then 99 times out of 100, you can see her.
Â
You can also teach her to ask before she hugs someone. While most of the women at Walmart are probably thrilled to be hugged by a 3 year old, not everyone will be. It's good basic in our culture manners to ask before you touch/hug someone.
Â
You should also teach her what to do if she gets 'lost' (I don't know the nature of your custody battle, but you should be able to describe what 'lost' means). If she gets separated from you, teach her to find a woman and say "I can't find my mom." Best is a woman with kids, next best is a woman without kids. This is straight from Protecting the Gift -- women have a much much lower incidence of child molestation and so are a safer choice if you have to approach a stranger. (And this is another reason you don't want to teach her to fear strangers -- if she's lost she'll HAVE to.)
Â
So, read Protecting the Gift. Teach her to stay with you. If you're worried about an ex snatching her, move heaven and earth to get a custody order in place and/or a restraining order. As she gets older, you can teach her more about trusting her own gut. Even the most extroverted person won't hug everyone.