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
1 Answer
Reset to default 0yes, 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
版权声明:本文标题:editor - Function to consider a plugin activated for selected users only 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736304672a1932317.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论