Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form name="loginform-custom" id="loginform-custom" action="http://localhost/wp-login.php" method="post">
- /**
- * Redirect user on invalid log-in attempts
- */
- function login_failed() {
- wp_redirect( home_url('/access-denied') );
- exit;
- }
- add_action( 'wp_login_failed', 'login_failed' );
- function verify_username_password( $user, $username, $password ) {
- if( $username == "" || $password == "" ) {
- wp_redirect( home_url('/access-denied') );
- exit;
- }
- }
- function restrict_admin_with_redirect() {
- if ( ! current_user_can( 'manage_options' ) && ( ! wp_doing_ajax() ) ) {
- wp_redirect( site_url('/404') );
- exit;
- }
- }
- add_action( 'admin_init', 'restrict_admin_with_redirect', 1 );
- add_action( 'init', 'force_404', 1 );
- function force_404() {
- $requested_uri = $_SERVER["REQUEST_URI"];
- do_action('debugger_var_dump', $requested_uri, '$requested_uri', 0, 0);
- do_action('debugger_var_dump', strpos( $requested_uri, '/wp-login.php'), 'FOUND?', 0, 0);
- if ( strpos( $requested_uri, '/wp-login.php') !== false ) {
- do_action('debugger_var_dump', 'REDIRECT', 'REDIRECT', 0, 0);
- // The redirect codebase
- status_header( 404 );
- nocache_headers();
- include( get_query_template( '404' ) );
- die();
- }
- if ( strpos( $requested_uri, '/wp-login.php') !== false || strpos( $requested_uri, '/wp-register.php') !== false ) {
- do_action('debugger_var_dump', 'REDIRECT', 'REDIRECT', 0, 0);
- // The redirect codebase
- status_header( 404 );
- nocache_headers();
- include( get_query_template( '404' ) );
- die();
- }
- if ( strpos( $requested_uri, '/wp-admin') !== false && !is_super_admin() ) {
- do_action('debugger_var_dump', 'REDIRECT', 'REDIRECT', 0, 0);
- // The redirect codebase
- status_header( 404 );
- nocache_headers();
- include( get_query_template( '404' ) );
- die();
- }
- do_action('debugger_var_dump', 'END', 'END', 0, 0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement