Developers

Redirect Visitors To Login (Force Login Page)

If you want to create a login-based website and need to redirect all your visitors to the login page, add this code to your theme’s functions.php file.

function protect_whole_site() {
   if (!is_user_logged_in()) {
     if (isset($_SERVER['REQUEST_URI'])) {
        $url = untrailingslashit($_SERVER['REQUEST_URI']);
        if (strpos($url, HMWP_Classes_Tools::getOption('hmwp_login_url')) === false) {
           wp_redirect(site_url('wp-login.php'));
           exit();
        }
    } else {
        wp_redirect(site_url());
        exit();
    }
  }
}
add_action('template_redirect', 'protect_whole_site');

If you have Ghost mode activated in WP Ghost, the redirect will made to the new login path.

John Darrel

  • Hi John, I was just wondering if you would be interested in building couple of plugins for me for my project? If yes, please reach out to me via email: niishcloud@gmail.com

    Thank you so much!!!

Change Database Prefix in WordPress

Because hackers often use bots to search for security flaws in your website, it is…

1 year

Customize WordPress Uploads Directory

The easiest way to change the default media uploads path is to use the WP…

1 year

WP Ghost and WP Rocket Cache

To hide all CSS and JS you need to follow the steps to Combine the…

1 year

Why is website security important?

https://youtu.be/6ylhojSi-_E In this video, we’ll explore why website security matters and what can happen if…

1 year

Is WordPress Website Easily Hacked?

The security of your WordPress site depends on multiple factors, such as the strength of…

1 year

Setting up Two-Factor Authentication (2FA) for WordPress Using Mobile Apps

When you enable two-factor authentication (2FA) for your WordPress website, it adds an extra layer…

1 year