trying to create simple plugin to filter categories from all authors

Plugins run a lot earlier than themes – you need to delay the execution using a hook: /** * Fire once WordPress is ready and conditionally hook our handler. */ function wpse_199197_init() { $user = wp_get_current_user(); $allowed_roles = array( ‘author’ ); if ( array_intersect( $allowed_roles, $user->roles ) ) add_filter( ‘get_terms_args’, ‘wpse_77670_filterGetTermArgs’, 10, 2 ); } … Read more

Add Admin menus or submenus depending on conditions

I managed to find a solution: File 1: //Count the number of active plugins whose Author is “My Brand”, and store the number in a global variable. $GLOBALS[‘mybrand_active_plugins’]=0; if (!function_exists(‘get_plugins’)){require_once ABSPATH.’wp-admin/includes/plugin.php’;} $plugins=get_plugins(); $activated_plugins=get_option(‘active_plugins’); foreach ($activated_plugins as $p){ if( (isset($plugins[$p])) AND ($plugins[$p][‘Author’]==’My Brand’)){ $GLOBALS[‘mybrand_active_plugins’]++; } } // Add menus on sidebar if($GLOBALS[‘mybrand_active_plugins’]<2) { function sub1_setup_menu() { … Read more