How can I let a characters Bone stick to a surface?

As the title suggestions, I’m trying to let a bone; For example a foot, stick to another actor, so that when he tries to move, he stucks.

Here is an illustration of what I mean:

In the first Picture you can see a character coming up to a cube.
In the second Picture you can see him sticking to the surface with one leg.
In the third Picture you can see him falling over, while his leg is still attached to the surface.

It doesn’t need to be exactly as what I have described just a rough direction on which nodes I need to use for that.