How to Add a WordPress Administrator Account Using PHP Code?

How to Add a WordPress Administrator Account Using PHP Code?

Adding an administrator user to your WordPress website is something you may need to do from time to time. Bloggers are now allowing guest authors to contribute to their blogs. While it is clear that managing a website on your own is not difficult, you may want assistance.

In most cases, you won't need to deal with codes when adding a new user, but if you forget your login credentials or your login limit plugin prevents you from logging in, you'll need to establish a new administrator account, which can only be done through cPanel. You can use phpMyAdmin, which requires a SQL query and I'm sure you don't know anything about database code.

It's preferable to utilise a function and then delete it once the job is completed. Isn't it incredible that you can add and deactivate a WordPress administrator user using PHP? Generally, you would copy, paste, and leave the code in the file, but not with this approach. You'll learn the fundamentals of WordPress functions and how to use them.

functions.php File Edit:

If you're a techie, you're probably already aware that the functions.php file houses the functions of a WordPress website. Allow me to simplify things for you. Functions.php is the main file in any WordPress theme that controls all of the layout's functionalities; you may use it to improve your existing website's features.

You can change the file from your wp-admin panel, but you'll need to use cPanel if you don't have access to it. I'll take you to step by step through the procedure.

Stick to the steps:

Step 1
: Log in to your cPanel account and go to File Manager. It's easy to find under the Files area.

You may locate the file manager depending on the web hosting business you choose.
Although the layout may differ, the options are similar.

Step 2: If you just have one domain name, the data is stored in the root directory. If you click on public_html from the left-hand sidebar, you may be able to view the home directory.

You can now view all of your WordPress website's files and directories. Open the wp-content folder by searching for it.

Step 3: As you can see on this screen, the folder contains your site's plugins, themes, and media files.

You must, as you are aware, open the themes folder.

Step 4: Here you can view all of the active and deactivated themes on your website. Open the folder containing your active theme.

Step 5: Locate and right-click the functions.php file to modify it. You may also utilise the Edit link found on cPanel's main horizontal navigation menu.

Step 6: At the bottom of the code editor, paste the code.

Save your changes by clicking the Save Changes button.

Note: Make sure the "Username" and "Password" in the code are changed. It's also a good idea to alter your email address.

You have a lot of options when it comes to completing work. Many users rely on the WordPress admin panel, yet they get upset if the website goes down or if their login credentials are lost. You may also try to retrieve the password, however, this isn't always possible because the security plugin prevents access.

The only way out is to create a new user account, which you can do if you know how to use cPanel. Many people are afraid of PHP, yet all you have to do is copy, paste, and delete the code.

Learning the fundamentals of cPanel is critical. cPanel is the ideal weapon for a WordPress website. Although many websites use managed web hosting and the NGINX server, this is not the case for all of them. The majority of small company owners use shared web hosting, which includes cPanel. I'm hoping you'll be able to quickly create a new administrator account.
Author
kumkumsharma
Views
1,645
First release
Last update
Rating
0.00 star(s) 0 ratings

More resources from kumkumsharma

Top