I have developed a WordPress Website. It's on the live server but in development mode.I want if someone to visit my website. It should ask for password or access token to before loading site.
Is there a way to achieve this functionality.
Note: I have put my code in the answer that's working. Please review it. Is this the good way or there is any better way to do this.