I’ve already written about WP-CLI a few times, but I’ll define it as an extremely helpful line command tool to manage sites built with WordPress. You can find more information about WP-CLI on its official site: wp-cli.org.
On today’s tip, I will explain how to update the WordPress Admin Email Address, which can be manually edited on WP-Admin > Settings > General > Administration Email Adress.
Updating the Admin Email
It’s possible to update the admin email with WP-CLI by running the following command, replacing NEW-EMAIL with the email address you want to set:
$ wp option update admin_email NEW-EMAIL
After running that command or manually editing the email address on WP-Admin > Settings > General > Administration Email Address, this message will be displayed:
There is a pending change of the admin email to NEW-EMAIL.
It means it is necessary to manually approve the change by accessing the email inbox and clicking on the link sent by WordPress to apply the changes to your site.
What can I do if I don’t want to manually approve the change?A very curious person
First, we need to understand that manual approval exists to add more security to WordPress. Still, there is something we can do to streamline this process without manually approving it. After all, you already have SSH access to the site, giving you great powers (and responsibilities).
Approving a pending change
If you are sure that the email address provided is correct and want to expedite the change process without manually approving it, you can use this command following the previous command to update the
$ wp option update new_admin_email NEW-EMAIL
Done! The email change is approved by updating the new_admin_email option with the same email address previously provided in admin_email, and the message indicating a pending change is immediately removed.
If necessary, you can clear the server cache using this other command:
$ wp cache flush
These commands can be very helpful for those who manage a single WordPress installation, but they are extremely useful and can save hours of manual work for those who manage hundreds of sites. How?
You can create a script to access each of the sites you manage and run the three commands simultaneously instead of manually accessing each dashboard or SSH.
I hope you enjoyed the tip.