Return to Snippet

Revision: 72642
at October 7, 2017 20:46 by cusmin


Initial Code
// HIDE CUSMIN

//Cusmin admin user ID
const CUSMIN_ADMIN_USER_ID = 1;

function hide_cusmin_from_plugins_list() {
	if(get_current_user_id() == CUSMIN_ADMIN_USER_ID){
		return;
	}
	global $wp_list_table;
	$hidearr = array('cusmin/cusmin.php');
	$myplugins = $wp_list_table->items;
	foreach ($myplugins as $key => $val) {
		if (in_array($key,$hidearr)) {
			unset($wp_list_table->items[$key]);
		}
	}
	remove_submenu_page('options-general.php','cusmin');
}
function remove_cusmin_options_page() {
	if(get_current_user_id() == CUSMIN_ADMIN_USER_ID){
		return;
	}
	//Removes cusmin link from admin menu
	global $pagenow;
	remove_submenu_page('options-general.php','cusmin');

	//Redirects from Cusmin options page to admin homepage
	if ( $pagenow == 'options-general.php' && !empty($_GET['page']) && $_GET['page'] == 'cusmin' ) {
		wp_redirect( admin_url() );
		exit;
	}
}
add_action( 'pre_current_active_plugins', 'hide_cusmin_from_plugins_list' );
add_action( 'admin_init', 'remove_cusmin_options_page', 999);
// HIDE CUSMIN

Initial URL
https://cusmin.com

Initial Description
Hide Cusmin plugin appearance from all other users, even administrators.
Add this code to active themes's functions.php

Initial Title
Hide Cusmin Appearance in WordPress

Initial Tags
plugin

Initial Language
PHP