Skip to content

Instantly share code, notes, and snippets.

@kingkool68
Created February 3, 2015 15:15
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 kingkool68/16abf2b3dcc4f39b2201 to your computer and use it in GitHub Desktop.
Save kingkool68/16abf2b3dcc4f39b2201 to your computer and use it in GitHub Desktop.
<?php
/**
* Plugin Name: Only Certain Logins Allowed
* Description: Only let certain usernames do anything...
* Version: 1.0
* Author: Russell Heimlich
* Author URI: https://twitter.com/kingkool68
*/
function only_certain_logins_allowed() {
$allowed_usernames = array( 'trotton', 'rheimlich' );
$user = wp_get_current_user();
if( !in_array( $user->user_login, $allowed_usernames) ) {
wp_die( 'Maintence Mode: you\'re not allowed. Ask Tracy ¯\_(ツ)_/¯' );
}
}
add_action( 'init', 'only_certain_logins_allowed' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment