'Remove wp-login completely

First of, I'm new to using Wordpress so please excuse me if I ask something really stupid.

I want to completely remove wp-login and the register function, I don't want users to be able to register and don't want to show the option on my blog.

I did some research on this and all i get are results that explain how to hide the wp-login or change the url, which is not what i want. Is there a function within wordpress to completly remove this from my blog? Or do i have to remove these pages from my source code?

Any help would be appreciated. Thank you.



Solution 1:[1]

Untick "Anyone Can Register" in "Settings" > "General" - I think that will take care of it. If you insist on taking the form down completely then this function would completely remove the login form, and yet still provide emergency access:

  add_filter( 'wp_login_errors', 'my_login_lock_down', 90, 2 );

  function my_login_lock_down( $errors, $redirect_to ){
  // Get to the login form using:  http://example.com/wp-login.php?secretform=secretcode
  $secret_key = "secretform";
  $secret_password = "secretcode";
  
  if ( !isset( $_GET[ $secret_key ] ) || $_GET[ $secret_key ] != $secret_password ) {
    login_header(__('Log In'), '', $errors);
    echo "</div>";
    do_action( 'login_footer' );
    echo "</body></html>";
    exit();
  }
  
  return $errors;
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1