WordPress as a Facebook app

The answer is…

Use Javascript for redirect, and redirect in each if statement.