Last active
August 29, 2015 14:21
-
-
Save JudeRosario/f513637d1939a42b4fc0 to your computer and use it in GitHub Desktop.
Code to force non admin users to redirect from wp-admin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Admin Redirect | |
Description: Code to force non admin users to redirect out of wp-admin | |
Author: WPMU DEV | |
*/ | |
add_action( 'wp', 'force_404' ); | |
function force_404() { | |
if ( $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] == 'http://example.com/wp-login.php' | |
|| $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] == 'http://example.com/wp-register.php' | |
|| $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] == 'http://example.com/wp-admin.php' ) | |
// The redirect codebase | |
status_header( 404 ); | |
nocache_headers(); | |
include( get_query_template( '404' ) ); | |
die(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment