When any state or county official shall have collected or paid out any money as fees, salary or compensation for official services rendered under any law of Alabama, general or special, which law, subsequent to such collection or paying out, shall be declared by the Supreme Court of Alabama to be unconstitutional or void or illegal, such officer shall not be liable either individually or on his official bond in any civil action brought for the recovery of such money so collected or paid out, nor shall the person to whom the same shall have been paid be liable therefor.
Ala. Code § 36-5-24 (1975)