hide it how? from the menu? or from the list of plugins? or both?
Hide it from the plugin list. So they are not aware of its presence and consequently prevent a misconfiguration. Thanks.
It sounds like user roles ARE required. A user set up with the administrator role has “god-mode” status to the site and anything you put in to hide stuff from an administrator can be bypassed by them.
To put it simply, if you can’t trust someone to not mess things up they should not be an administrator.
Have a look at Justin Tadlock’s members plugin to help set your roles & capabilities more appropriately.
put this in functions.php of your theme, adjust the array to be whatever one/ones you want to hide. NOTE: the values in the array are the path and name of the main file from the plugin.
function mytest() {
global $wp_list_table;
$hidearr = array('hello.php');
$myplugins = $wp_list_table->items;
foreach ($myplugins as $key => $val) {
if (in_array($key,$hidearr) {
unset($wp_list_table->items[$key]);
}
}
}
add_action( 'pre_current_active_plugins', 'mytest' )
@luckdragon: Thanks for answering. I’ll try this.
@cubecolour: I set up my users as admins ’cause they’re supposed to be owners of the web site (I’m just the tech guy). I want them to be able to install and edit their own plugins, but not those ones that are critical in technical terms.
if you are having problems, mouse over the “Edit” link, it will say like:
http://whatever.com/wp-admin/plugin-editor.php?file=favlinks/favlinks.php
and
http://whatever.com/wp-admin/plugin-editor.php?file=discography/discography.php
whatever you see in file= is what you put in the array:
so if you wanted to exclude both of those you’d do:
$hidearr = array('favlinks/favlinks.php','discography/discography.php');
Thanks, here’s what I did but throws “Server Error”
function mytest() {
global $wp_list_table;
$hidearr = array('background-per-page/background-per-page.php');
$myplugins = $wp_list_table->items;
foreach ($myplugins as $key => $val) {
if (in_array($key,$hidearr) {
unset($wp_list_table->items[$key]);
}
}
}
add_action( 'pre_current_active_plugins', 'mytest' )
probably my fault in the original post
if (in_array($key,$hidearr) {
should be:
if (in_array($key,$hidearr)) {
Thanks for this. I am working on some code where I want to move a child plugin out from underneath its parent plugin to become a standalone plugin and was researching what I could do with ‘pre_current_active_plugins’. I was going to raise a request to have the action converted into a filter so that I could alter the values of the $plugins array passed into it but since it seems that I can make changes to the $wp_list_table then I’ll try this first.
With regards to the original subject. Is it not just possible to make
the plugin a Must Use plugin? http://codex.wordpress.org/Must_Use_Plugins
this isn’t for whether or not a plugin gets used, it’s for whether or not other admins have access to the plugin settings and the like via the administration area