Tip: Remaking levels from other Mario games is strongly discouraged, especially popular ones (World 1-1 from SMB or SMB3, for example), as their over-presence in Mario games, official or not, often makes them uninteresting to play.
With this code, you can check if any overworld level flags are set and if they are, set any other level flags (the ones on the right you can see in overworld level settings window). This allows you to open any path on the overworld, not only a path from the level you have just beaten.
Simply change the defines in the asm file.
Credit is optional, just don't claim it as your own.