I'd like to hide my admin login, since it was disabled some time ago because of attacks. (I do not remember what they were exactly, my site was down for another reasons long time)

I know there are several plugins to do this, but I would like to use my own code.

Has anyone done this before, and is it possible to add this to theme functions.php?

I have already searched but found no tutorial on the internet, but could this example be a starting point? Changing wp login url without .htaccess

I have written my own template with functions already, but this is far more complex, so hope to get some hints from fellow more experienced wordpress coders. Sorry if this is a dumb question

1 Answer 1


There is an action hook called login_init. It's also called on the registration page. You can simply attach wp_die() to it. You might want to disable the entire backend as well, which can be done by hooking into admin_init.

add_action( 'login_init' , 'wp_die' );
add_action( 'admin_init' , 'wp_die' );

WordPress will exit with an empty message box.

To leave a message do as follows following:

function go_away() {
    wp_die( 'Nice meeting you, byebye.' );
add_action( 'login_init' , 'go_away' );
add_action( 'admin_init' , 'go_away' );
  • Not exactly related to your question: For a better code maintainability I think it's be better to place the above code in a mu-plugin. See codex.wordpress.org/Must_Use_Plugins
    – Jörn Lund
    Jun 14, 2014 at 9:17
  • 2
    Thank you very much! But this means I cannot use the admin login at all?
    – Owl
    Jun 14, 2014 at 20:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.