المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : ووردبريس WordPress اضافة ادمن جديد من خلال ملف فنكشن Add an Admin User using FTP



Rise Company
13-08-2023, 00:39
ووردبريس WordPress اضافة ادمن جديد من خلال ملف فنكشن Add an Admin User using FTP

Being locked of your WordPress admin is frustrating. That’s why we have shown you how to add an admin user in WordPress via MySQL. Recently one of our readers asked if it was possible to add an admin user in WordPress using FTP. Ofcourse it is. In this article, we will show you how to add an admin user in WordPress using FTP.


https://www.rise.company/forum/images/imported/2023/08/1.jpg
Why You May Need to Add an Admin User in WordPress Using FTP?Sometimes you may forget your username or email address on a WordPress site and cannot login to the admin area.
One way to do this is by adding an admin user to the WordPress database using MySQL. But you may be unable to connect to phpMyAdmin or don’t want to run MySQL queries directly.
Some users may get their site hacked and admin account deleted. In that case, adding an admin user using FTP can quickly restore your access to the WordPress admin area.
Having said that, let’s see how you can easily add an admin user in WordPress using FTP access.
Adding an Admin User in WordPress Using FTPFirst thing you will need is an FTP client. If you are new to using FTP, then see our guide on how to use FTP to upload files in WordPress.
Once connected to your WordPress site, you need to locate your WordPress theme’s functions.php file. It would be at a location like this:
/yoursite.com/wp-content/themes/your-current-theme/functions.php
Right click on functions.php file and then select download. Your FTP client will download the functions.php file to your computer.


https://www.rise.company/forum/images/imported/2023/08/1.png


Open the file you just downloaded on your computer using a plain text editor like Notepad. Now you need to add this code at the bottom of the file.


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');


Don’t forget to replace Username, Password, and [email protected] with your own values.
Next, save the file and then upload it back to your website using the FTP client.
You can now visit your WordPress site’s login area and sign in with the user account you just added.


Once you have logged in to your WordPress site, please edit the functions.php file and delete the code you added. Deleting the code will not remove the user you added, and you can always add new users and authors to your WordPress site.


المرجع:
https://www.wpbeginner.com/wp-tutorials/how-to-add-an-admin-user-in-wordpress-using-ftp/