A pillared layer MOF with anion-tunable magnetic properties and photochemical [2 + 2] cycloaddition.