Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@JudeRosario
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JudeRosario/f513637d1939a42b4fc0 to your computer and use it in GitHub Desktop.
Save JudeRosario/f513637d1939a42b4fc0 to your computer and use it in GitHub Desktop.
Code to force non admin users to redirect from wp-admin
<?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