Disable WordPress Updates for Specific User Roles
Disabling WordPress updates for specific user roles is crucial for maintaining control over your site’s functionality and preventing unwanted changes. To achieve this, you can use custom code snippets added to your theme’s functions.php
file or a site-specific plugin.
In the example code, only administrators can see the update notifications and update a plugin for your WordPress website. However, you can also make changes in this code to add other user roles as well as per your need.
/**
* Disable WordPress Updates for Specific User Roles.
*
* @return object
*/
function pt_disable_updates() {
global $wp_version;
return (object) array( 'last_checked' => time(), 'version_checked' => $wp_version, );
}
add_action( 'init', function () {
if ( ! current_user_can( 'administrator' ) ) {
// Disable WordPress core updates
add_filter( 'pre_site_transient_update_core', 'pt_disable_updates' );
// Disable WordPress plugin updates
add_filter( 'pre_site_transient_update_plugins', 'pt_disable_updates' );
// Disable WordPress theme updates
add_filter( 'pre_site_transient_update_themes', 'pt_disable_updates' );
}
} );
If you are not developer or You don’t want to edit your theme’s file then you can install the Disable WordPress Update Notifications and auto-update Email Notifications plugin. This plugin will completely disables the Plugins, Themes, and WordPress core update notifications displayed by WordPress based on your plugin settings.