Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A little one file WordPress plugin that will disable the authors single template (don't enable this plugin it if you use the author's template) and redirect bots that try to connect with the ''admin" username to my favorite NSFW website. Cheers!
<?php
/*
Plugin Name: Go F Yourself
Description: Disable '?author=n' view and redirect people trying to login with the "admin" user
Version: 1.0
Author: Benjamin Niess
Author URI: http://twitter.com/benjaminniess
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
class Go_Fuck_Yourself {
function __construct() {
add_action( 'wp_authenticate', array( __CLASS__, 'fuck_admin_login' ) );
add_action( 'template_redirect', array( __CLASS__, 'disable_author_page' ), 1 );
}
/**
* If someone tries to login with the username 'admin' => redirect to my favourite website
*/
public static function fuck_admin_login( $login = '' ) {
if ( 'admin' != $login ) {
return false;
}
wp_redirect( 'http://www.french-bukkake.com' ); // This is an example.
exit;
}
/**
* If someone tries to reach a page like homepage/?author=1 to get the name of the first user => redirect to the HP
*/
public static function disable_author_page() {
if ( ! is_author() ) {
return false;
}
wp_redirect( home_url( '/' ) );
exit;
}
}
// Init the plugin
function gfy_init() {
new Go_Fuck_Yourself();
}
add_action( 'plugins_loaded', 'gfy_init' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.