Cách tạo User Admin Wordpress bằng Code trên FTP
Đôi lúc bạn có thể quên user và password của admin. Trong trường hợp đó, bạn có thể tạo một tài khoản admin bằng cách sử dụng FTP. Như vậy bạn có thể nhanh chóng khôi phục được quyền truy cập vào khu vực admin WordPress.
Chèn đoạn code sau vào cuối file functions.php:
function wpb_admin_account(){ $user = 'Username'; $pass = 'Password'; $email = '[email protected]'; 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','wpb_admin_account');
Khi bạn đã đăng nhập vào trang web WordPress của bạn, bạn phải xóa đoạn code mới chèn vào file functions.php.
Đăng nhận xét
0 Nhận xét