How to make an object that collides with just the player?

Note: If other objects are in front he can pass through them.

The simplest way to do this is with layers,

if you go to the Edit → Project Settings → Physics you’ll be greeted with this in the inspector

Now all you have to do is create a new layer for the player, the objects in question, and finally the objects you wish it to pass through, and then uncheck the collision in this matrix so they don’t collide.

(So like in this I could make it so “Default” and “Water” don’t collide by unchecking where the default line goes under the water on the top.)