How to restrict a WordPress site without plugins

Adding plugins to your WordPress site can slow it down, break it, or even add new security vulnerabilities. If you need your website to be private, meaning that nobody will be able to access any pages unless they are signed in. Then, this code below can help you achieve this goal. No need to add another plugin. Simply add the following hook to your WordPress Theme’s funtion.php.

// Require login for site
get_currentuserinfo();
global $user_ID;
if ($user_ID == '') { 
header('Location: /wp-login.php'); exit(); 
}

When it comes to WordPress customizations HiXFi can provide you the support you need. We can help you customize your WordPress site or integrate any feature. Schedule a call with us today!

Comments are closed.