Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. <form name="loginform-custom" id="loginform-custom" action="http://localhost/wp-login.php" method="post">
  2.  
  3. /**
  4. * Redirect user on invalid log-in attempts
  5. */
  6. function login_failed() {
  7. wp_redirect( home_url('/access-denied') );
  8. exit;
  9. }
  10. add_action( 'wp_login_failed', 'login_failed' );
  11.  
  12. function verify_username_password( $user, $username, $password ) {
  13. if( $username == "" || $password == "" ) {
  14. wp_redirect( home_url('/access-denied') );
  15. exit;
  16. }
  17. }
  18.  
  19. function restrict_admin_with_redirect() {
  20. if ( ! current_user_can( 'manage_options' ) && ( ! wp_doing_ajax() ) ) {
  21. wp_redirect( site_url('/404') );
  22. exit;
  23. }
  24. }
  25. add_action( 'admin_init', 'restrict_admin_with_redirect', 1 );
  26.  
  27. add_action( 'init', 'force_404', 1 );
  28.  
  29. function force_404() {
  30. $requested_uri = $_SERVER["REQUEST_URI"];
  31. do_action('debugger_var_dump', $requested_uri, '$requested_uri', 0, 0);
  32. do_action('debugger_var_dump', strpos( $requested_uri, '/wp-login.php'), 'FOUND?', 0, 0);
  33.  
  34. if ( strpos( $requested_uri, '/wp-login.php') !== false ) {
  35.  
  36. do_action('debugger_var_dump', 'REDIRECT', 'REDIRECT', 0, 0);
  37. // The redirect codebase
  38. status_header( 404 );
  39. nocache_headers();
  40. include( get_query_template( '404' ) );
  41. die();
  42. }
  43.  
  44. if ( strpos( $requested_uri, '/wp-login.php') !== false || strpos( $requested_uri, '/wp-register.php') !== false ) {
  45.  
  46. do_action('debugger_var_dump', 'REDIRECT', 'REDIRECT', 0, 0);
  47. // The redirect codebase
  48. status_header( 404 );
  49. nocache_headers();
  50. include( get_query_template( '404' ) );
  51. die();
  52. }
  53.  
  54. if ( strpos( $requested_uri, '/wp-admin') !== false && !is_super_admin() ) {
  55.  
  56. do_action('debugger_var_dump', 'REDIRECT', 'REDIRECT', 0, 0);
  57. // The redirect codebase
  58. status_header( 404 );
  59. nocache_headers();
  60. include( get_query_template( '404' ) );
  61. die();
  62. }
  63.  
  64. do_action('debugger_var_dump', 'END', 'END', 0, 0);
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement