admin管理员组

文章数量:1122832

Our WP-based website is maintained by a company that forced the use of Gutenberg upon us, moreover, for some reason, the Classic Editor plugin doesn't work properly on the website probably due to some awful code customizations in the used template - the CE plugin when activated switches the Gutenberg off for all users without any customizable options or switches between the Gutenberg and the classic editor.

Is it possible to make a function that will switch on the Classic Editor plugin only for a handful of selected users?

Something like:

$CE_users = array('user1', 'user2');
if(is_user_logged_in() && in_array($current_user->user_login, $CE_users)){
    //somehow load plugin Classic Editor
    }

Our WP-based website is maintained by a company that forced the use of Gutenberg upon us, moreover, for some reason, the Classic Editor plugin doesn't work properly on the website probably due to some awful code customizations in the used template - the CE plugin when activated switches the Gutenberg off for all users without any customizable options or switches between the Gutenberg and the classic editor.

Is it possible to make a function that will switch on the Classic Editor plugin only for a handful of selected users?

Something like:

$CE_users = array('user1', 'user2');
if(is_user_logged_in() && in_array($current_user->user_login, $CE_users)){
    //somehow load plugin Classic Editor
    }
Share Improve this question asked May 22, 2024 at 16:47 Yuri ZoriaYuri Zoria 1
Add a comment  | 

1 Answer 1

Reset to default 0

yes, this is possible by creating a new function because thank to wordpress function activate_plugin() that can be used to activate the classic editor plugin for specific users

// Define the usernames of the users who should have the Classic Editor 
enabled
$CE_users = array('user1', 'user2');

// Check if the current user is logged in and their username is in the array 
of CE users
if (is_user_logged_in() && in_array($current_user->user_login, $CE_users)) {
// Activate the Classic Editor plugin
activate_plugin('classic-editor/classic-editor.php');
}

Add this code into Your theme functions.php file of your child theme and see it’s working or not

本文标签: editorFunction to consider a plugin activated for selected users only