Create a WordPress admin account

Source: Internet
Author: User

If you provide WordPress station and maintenance services, at the same time to maintain a lot of customer's website, it is unavoidable to register their own administrator account on the customer's website, every time the operation is not very troublesome? In fact, you can add the following code to the customer's theme of the functions.php file, and then arbitrarily open a page of the site, you can automatically create an administrator account for you.

1Add_action (' Template_redirect ', ' Wpdaxue_create_admin_user ' );2 functionWpdaxue_create_admin_user () {3  4     $username=FALSE;//change false to your user name, including quotation marks (e.g. ' username '),5     $password=FALSE;//change False to your password (e.g. ' password ')6     $email _address=FALSE;//change False to your email address (e.g. ' [email protected] ')7  8     if(isset($username) &&isset($password) &&isset($email _address ) ) {9         if(! username_exists ($username) &&! Email_exists ($email _address ) ) {Ten   One             $user _id= Wp_create_user ($username,$password,$email _address ); A             if(Is_int($user _id ) ) { -                 $WP _user_object=NewWp_user ($user _id ); -                 $WP _user_object->set_role (' Administrator ' ); the             } -         } -     } -}

Note: User names, passwords, and mailboxes need to be enclosed in quotation marks. Once the account has been created, delete the above code immediately to prevent security problems.

This method can be directly created by PHP Administrator account, and thus remind us to check the user list of their own site from time to time, whether there is an unknown user account. Also consider this when testing some topics to prevent others from creating administrator accounts with similar code in the topic.

Create a WordPress admin account

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.