Command block to give specific player (in a certain radius) a status effect

In Vanilla Minecraft 1.18, is there a way to give a specific player a status effect if they step within X blocks of an area? I need to give Mining Fatigue on a certain player when they enter my base.

After extensive searching I've looked at the command /effect give

/effect give playerName minecraft:absorption 5 5 true

and also /testfor, but that doesn't seem to work.

The effect should only happen when a certain player is within a certain radius of the command block.


This should work:

/effect give @a[name=playerName,distance=..radius] minecraft:absorption 5 5 true