Testing WordPress Access Control using an MU Plugin
WARNING - MU plugin file for testing purposes only.
If you don't want to use the plugin and instead want to use a coded solution, the following below could be done for testing purposes. We highly recommend on using a plugin like User Switching over this method. The plugin method is likely to offer better security and it will be easier for most people.
Must-use plugins (a.k.a. mu-plugins) are plugins installed in a special directory inside the content folder and which are automatically enabled on all sites in the installation. Must-use plugins do not show in the default list of plugins on the Plugins page of wp-admin – although they do appear in a special Must-Use section – and cannot be disabled except by removing the plugin file from the must-use directory, which is found in wp-content/mu-plugins by default.