How to Hide Fields or Menus in WordPress Plugins

Wordpress

How to Hide Fields or Menus in WordPress Plugins

Hello friends, welcome back! This time, we will discuss how to hide a field, column, or menu in WordPress plugins. This trick is particularly useful when we, as developers, hand over the dashboard access to clients. There are some menus that we need to hide, especially if the menu could potentially confuse or mess up the settings if accessed by the client. For example, we will discuss how to hide the license key menu in the Security Ninja and Permalink Manager Pro plugins.

Hiding the License Key in the Security Ninja Plugin

Step 1: Identify the Element to be Hidden

First, we need to identify the element to be hidden. In the Security Ninja plugin, there is an account menu that contains the license key menu. When this menu is clicked, the license used will be displayed, and we do not want this to happen.

Step 2: Inspect Element and Get the Element ID

Inspect the element of the menu to find its ID. In this case, the ID is fs_account. Copy this ID.

Step 3: Add a Function to Hide the Element

Go to the Plugin Editor menu, then select the config.php file from the Security Ninja plugin. Scroll to the bottom of the file. We will add a function to hide this element by adding CSS through PHP.

Here is the script to be added:

// Hiding the license key
function hide_license_key() {
    echo '<style>
    #fs_account {
        display: none;
    }
    </style>';
}
add_action('admin_print_styles', 'hide_license_key');

This script will call CSS to hide the element with ID fs_account.

Step 4: Update and Check the Result

After adding the script, update the file and refresh the WordPress dashboard page. The license key menu in the Security Ninja plugin will disappear.

Step 1: Identify the Element to be Hidden

In the case of Permalink Manager Pro, it does not use the Freemius licensing system like Security Ninja, so we need to adjust the script for this plugin.

Step 2: Inspect Element and Get the Element ID

Inspect the element of the menu you want to hide in Permalink Manager Pro to find its ID. For example, the ID is pm_license.

Step 3: Add a Function to Hide the Element

Go to the Plugin Editor menu, then select the permalink-manager.php file from the Permalink Manager Pro plugin. Scroll to the bottom of the file and add the following script:

// Hiding the license key for Permalink Manager Pro
function hide_license_key_pm() {
    echo '<style>
    #pm_license {
        display: none;
    }
    </style>';
}
add_action('admin_print_styles', 'hide_license_key_pm');

This script will call CSS to hide the element with ID pm_license.

Step 4: Update and Check the Result

After adding the script, update the file and refresh the WordPress dashboard page. The license key menu in the Permalink Manager Pro plugin will disappear.

Conclusion

These are some tricks to hide the license key column in WordPress plugins. In this example, we used two different licensing systems, namely Freemius for Security Ninja and the plugin’s built-in system for Permalink Manager Pro. I hope this trick is useful for those who need it. I am Riong Astri, see you next time!

Leave a Comment