Want to force user to login before view any site content in WordPress? Use the below example to code to force user to login before view any site content.
1 2 3 4 | if ( ( is_single() || is_front_page() || is_page() ) && !is_page('login') && !is_user_logged_in()){ auth_redirect(); } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.