How to force all users to log out of WordPress

How to force all users to log out of WordPress

There are different reasons to force all users to log out of WordPress. In this article we’ll cover the various reasons to force all users to log out and show you how to do it.

Why force all users to log out?

Why would you want to force all your users to log out? There many reasons to do this. For instance, if you have a lot of members on your WordPress site and your website gets hacked. Forcing all users to log out gives you the time to clean up your WordPress install.

Divi theme & Divi Builder
Elegant Themes is selling more than
85 premium themes (including Divi!) for only $89!
Check Elegant Themes »

If you’ve logged in to your WordPress admin account on a computer that is not yours, and you’re not sure whether you’ve logged out, this method will make sure that you’re logged out on all devices.

Let’s have a look at the different methods to force all users to log out.

Forcing all users to log out of WordPress

To force your users to log out, you’re going to edit the wp-config.php file. This file can be considered the “heart” of your WordPress install. If you make mistakes here, your website may become unaccessible or stop working. Therefore, I highly recommend to create a proper backup of your wp-config.php file. If you make a mistake, you’ll be able to easily revert to the previous version.

To edit the wp-config file, connect to your server using FTP (or use the File Manager in your hosting company’s control panel). Go to the root folder of your WordPress install and look for the file called wp-config.php.

wp-config file
The wp-config.php file in my FTP client.

Now, open the wp-config.php file and look for the following code:

If you can’t find a code that looks like the above, it may look like this:

These lines of code are called the “keys and salts”. To read more about keys and salts, please check out the WordPress Codex.

To force all users to log out, you’ll need to replace these “keys” with a fresh set of random strings. You can enter your own unique phrases, but it’s probably easier to visit this page that will automatically generate a random set of keys for you.

WordPress salts generator
WordPress salts generator

Copy the code on the page shown above, and replace the ones in your wp-config.php file. After saving the file (and re-uploading it to your WordPress install), all your users will be logged out and forced to log in again.

Roger Overdevest

Owner of WPLounge.nl, the biggest Dutch blog about WordPress.