Lost access to the site admin!

YvanM-34 Posted messages 753 Registration date   Status Member Last intervention   -  
Super.Mario Posted messages 584 Registration date   Status Member Last intervention   -
Hello,

Following the failure of my code manager, I need to reconstruct them. I am faced with the unpleasant surprise of being unable to locate the admin username and password for one of my sites, and my memory is faulty. The public site works normally. I haven’t added anything recently, but I occasionally check the admin to make sure everything is OK. Updates are performed automatically, so I must be on the latest WordPress version. I have access at my hosting provider to all system files, database, and others, but I am not skilled at digging through them. What procedures can be undertaken to recover my credentials?

Thank you.
Best regards,
Yvan

2 answers

  1. Didi64_549 Posted messages 2904 Registration date   Status Member Last intervention  
     

    Hello,

    The procedures are:

    1: your memory

    2: to see if you have written them somewhere on paper for example

    3: on this forum the charter clearly specifies: no assistance to recover passwords, etc...


    0
  2. Super.Mario Posted messages 584 Registration date   Status Member Last intervention   251
     

    Hello YvanM-3

    If you have FTP access to your hosting, you can access the functions.php file located in the wp-content/themes/XXXXX/ folder (the XXXXX folder is your active theme) of your Wordpress installation.

    Copy the functions.php file to your machine so you can modify it (always keep a backup before modifications, in case of error or failure of the operation).

    Add this code just after the <?php tag at the beginning of the file functions.php :

    function wpm_create_admin(){ $username = 'nom_nouvel_admin'; $password = 'motdepasse_nouvel_admin'; $email = 'email_nouvel_admin@domaine.com'; if ( ! username_exists( $username ) && ! email_exists( $email ) ) { $user_id = wp_create_user( $username, $password, $email ); $user = get_user_by( 'id', $user_id ); $user->set_role( 'administrator' ); } } add_action('init', 'wpm_create_admin'); 

    This will create a temporary Admin user on next access to your site and you can use it to access your Wordpress settings and change your official admin info if you forgot it.

    You will need to use the same manipulation and remove these added lines from this new account in functions.php after you have made changes to your official admin...

    Have a good day


    0