问题描述
我使用 Wordpress 创建了一个插件,我想创建一个只能访问该插件的用户帐户.
I have created a plugin using Wordpress and I would like to create a user account that ONLY has access to this plugin.
换句话说,当用户登录到 wordpress 管理面板时,这个插件是他们唯一看到的东西.
In other words when the user logs in to the wordpress admin panel this plugin is the only thing they see.
推荐答案
您可以使插件菜单可供用户级别的能力使用.正如您可以在 WordPress codex 中看到的,
You can make the menu of the plugin available to the user level's capability. As you can see in WordPress codex,
add_options_page('我的插件选项', '我的插件', 'manage_options', 'my-unique-identifier', 'my_plugin_options');
'manage_options' 是管理员的能力.订阅者的能力是读取",因此将manage_options"替换为读取",您将授予订阅者的访问权限.
'manage_options' is a capability of an administrator. A subscriber's capability is 'read', so replace 'manage_options' with 'read' and you'll give access to the subscriber.
这不仅适用于 add_option_page,还适用于 add_menu_page、add_plugins_page 等
This not only works with add_option_page, but also with add_menu_page, add_plugins_page, etc.
这是能力的完整列表.
这篇关于Wordpress - 仅限制对插件的访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!