We use cookies to improve our services and provide a better experience. By continuing to use this site, you agree with our Cookies Policy.

Tutorials
More than 400 step-by-step articles to guide you through online project development.
HomeTutorialsCMS TutorialsWordPress

How to a hide plugin from specific usernames

USA VPS
Germany Cloud Servers
cPanel KVM
Linux KVM Hosting
Windows Cloud Server
Linux Cloud Server
OpenVZ VPS
Brazil VPS
Ubuntu VPS
KVM VPS

If for some reasons we need to hide plugin from specific WordPress users, we can use simple PHP code. In this case, it will serve as a function and will be placed in WordPress theme functions.php file.

  • Find file functions.php. Usually it’s located in the current theme directory which can be found by going to wp-content/themes directory.
  • Open file functions.php for editing by using FTP client or built in file browser of hosting account.
  • Place the following code inside the file:
1
2
3
4
5
6
7
8
9
10
11
function hide_plugin() {
global $wp_list_table;
$array = array('file.php');
$plugins = $wp_list_table->items;
foreach ($plugins as $key => $val) {
if (in_array($key,$array) {
unset($wp_list_table->items[$key]);
}
}
}
add_action( 'pre_current_active_plugins', 'hide_plugin' )

Please note: values of the array are path and name of plugin file. If everything is done correctly, plugins listed in the array should be hidden from specific usernames.

Brazil VPS
cPanel KVM
Ubuntu VPS
Germany Cloud Servers
Windows Cloud Server
Linux Cloud Server
Linux KVM Hosting
USA VPS
KVM VPS
OpenVZ VPS
Rate this Tutorial:
No Comments Leave a Comment
Leave a Comment

Other (182)

Popular Keywords