Title: Privilege Menu
Author: FuzzGuard
Published: <strong>2014 年 3 月 30 日</strong>
Last modified: 2019 年 2 月 18 日

---

搜索插件

![](https://ps.w.org/privilege-menu/assets/banner-772x250.png?rev=1629643)

**该插件尚未通过WordPress的最新3个主要版本进行测试**。 当与较新版本的WordPress一起
使用时，可能不再受到维护或支持，并且可能会存在兼容性问题。

![](https://ps.w.org/privilege-menu/assets/icon-128x128.png?rev=1629639)

# Privilege Menu

 作者：[FuzzGuard](https://profiles.wordpress.org/fuzzguard/)

[下载](https://downloads.wordpress.org/plugin/privilege-menu.1.8.4.zip)

 * [详情](https://cn.wordpress.org/plugins/privilege-menu/#description)
 * [评价](https://cn.wordpress.org/plugins/privilege-menu/#reviews)
 *  [安装](https://cn.wordpress.org/plugins/privilege-menu/#installation)
 * [开发进展](https://cn.wordpress.org/plugins/privilege-menu/#developers)

 [支持](https://wordpress.org/support/plugin/privilege-menu/)

## 描述

This plugin allows you to display menu items based on if a user is logged in, logged
out or based on the role you have given the user.

This plugin allows fine-grained permissions to be added to each individual menu 
item to display or not display the item based on the
 users logged in/logged out
status or the role assigned to the user. This solves the problem of having to modify
theme functions.php files to add in menu restrictions. The changes in functions.
php is often overwritten by a theme update. This plugin removes that worry, as you
can update the theme, independent of the plugin.

#### Please Note

This plugin uses a modified version of the Nav Menu Walker class. This means any
other plugins that utilize their own custom Nav Menu Walker class, can and will 
conflict with this plugin. WordPress developers have support for proper custom hooks
in this area of the Admin Menu slated for v4.8 release. Please see FAQ item “I cannot
see the options for Privilege Menu under menu items in the Admin Panel?” for more
information.

## 屏幕截图

[⌊How to add an menu item as only viewable to logged IN users.⌉⌊How to add an menu
item as only viewable to logged IN users.⌉[

How to add an menu item as only viewable to logged IN users.

[⌊How to add an menu item as only viewable to logged OUT users.⌉⌊How to add an menu
item as only viewable to logged OUT users.⌉[

How to add an menu item as only viewable to logged OUT users.

[⌊This is the menu a logged IN user would see.  These users don't see "Login" due
to the fact that it is denied to logged IN users in the Admin Panel Nav Menus section.⌉⌊
This is the menu a logged IN user would see.  These users don't see "Login" due 
to the fact that it is denied to logged IN users in the Admin Panel Nav Menus section
.⌉[

This is the menu a logged IN user would see. These users don’t see “Login” due to
the fact that it is denied to logged IN users in the Admin Panel Nav Menus section.

[⌊This is the menu a logged OUT user would see.  These users don't see "Logout","
My Account" or "Control Panel" due to the fact that they are denied to logged OUT
users in the Admin Panel Nav Menus section.⌉⌊This is the menu a logged OUT user 
would see.  These users don't see "Logout", "My Account" or "Control Panel" due 
to the fact that they are denied to logged OUT users in the Admin Panel Nav Menus
section.⌉[

This is the menu a logged OUT user would see. These users don’t see “Logout”, “My
Account” or “Control Panel” due to the fact that they are denied to logged OUT users
in the Admin Panel Nav Menus section.

[⌊This is a view of a menu item you could select only to be viewable for administrators.⌉⌊
This is a view of a menu item you could select only to be viewable for administrators
.⌉[

This is a view of a menu item you could select only to be viewable for administrators.

## 安装

 1. Upload the `plugin` folder to the `/wp-content/plugins/` directory
 2. 通过WordPress的的“Plugins”菜单激活插件
 3. Go to Appearance > Menus
 4. Edit the menu items accordingly. First select whether you’d like to display the
    item to all logged in users, all logged out users or Both (Default).
 5. Save the changes to the menu. You should now see excluded menu items based on a
    users logged in/logged out state.

## 常见问题

  Can I localize this plugin for my own language?

Yes you can. Included now in this plugin is a folder call “lang”. Within this folder
is a file called “privilege-menu.pot”. This file can be used to create the localized
translations for your own language using poedit.

If you contact me after you have done this through my website at: https://www.fuzzguard.
com.au/contact/ I can include this translation file in the next plugin release. 
You will be credited for your work of course.

  I cannot see the options for Privilege Menu under menu items in the Admin Panel?

This usually occurs due to a plugin conflict. The Admin Menu Walker can only have
one custom walker so any other plugin that uses a custom Admin Menu Walker will 
cause conflicts with Privilege Menu plugin.

WordPress does not yet have sufficient hooks in this area of the admin panel. Due
to this plugins are forced to load a modified custom Admin Menu Walker. The custom
Admin Menu Walker is limited to one so only one Admin Panel menu modification plugin
can be active at one time.

Although this feature has been requested since 3.6 it still hasn’t been added to
the WordPress Core.
 There’s a possibility that support for “Nav Menu UI” Hooks 
will be added in WordPress 4.8 as it has now been picked up by the developers and
they are actively working on implementing this: https://core.trac.wordpress.org/
ticket/18584

  As a developer what hooks are there for this plugin?

There are two hooks that have been provided for this plugin. The first hook is: ‘
priv_menu_roles’. It can be used to allow other plugins to add roles to be checked
by ‘Privilege Menu’:
 add_filter( ‘priv_menu_roles’, ‘roles_to_add’, 10, 1 );

    ```
    function roles_to_add($roles /* WP_RoleNames Array */) {
        $roles['new_role'] = 'New Role';
        return $roles;
    }
    ```

The second hook is: ‘priv_menu_visibility’. It can be used for other plugins to 
filter the result for the front-end display of the menu items generated by ‘Privilege
Menu’:
 add_filter( ‘priv_menu_visibility’, ‘filter_FE_display’, 10, 2);

    ```
    function filter_FE_display($visibility /* Boolean */, $item /* WP_POST Object*/) {
        if ($item->ID == '470' || $item->title == 'Logout') {
                $visibility = true;
        }
        return $visibility;
    }
    ```

## 评价

![](https://secure.gravatar.com/avatar/db84fbc98ed3d139dd6e77829ab6100cf5c2e5391fa1f88b0515785796770dee?
s=60&d=retro&r=g)

### 󠀁[WOW! Works with MEGAMENU!](https://wordpress.org/support/topic/wow-works-with-megamenu/)󠁿

 [Doc GermaniCus](https://profiles.wordpress.org/doc-germanicus/) 2020 年 9 月 29
日

I have now tested countless plugins, none of them worked with my mega menu! And 
this part that has not been updated for a long time works perfectly! Thumbs up!

![](https://secure.gravatar.com/avatar/6b60b1a6044a7892e8210c58e095d5fe25577a8473157ecf01fbf2a6acbbaa15?
s=60&d=retro&r=g)

### 󠀁[Very Very Good](https://wordpress.org/support/topic/very-very-good-114/)󠁿

 [igota15](https://profiles.wordpress.org/igota15/) 2020 年 5 月 20 日

Muito Bom!! PQP . Salvou tudinho

![](https://secure.gravatar.com/avatar/242212350e629b795fa50db16478d939404c5435c5c0002d16dfb8552dba83a4?
s=60&d=retro&r=g)

### 󠀁[Perfect!](https://wordpress.org/support/topic/perfect-4010/)󠁿

 [peebz](https://profiles.wordpress.org/peebz/) 2017 年 5 月 1 日

A great plugin – much appreciated.

 [ 阅读所有7条评价 ](https://wordpress.org/support/plugin/privilege-menu/reviews/)

## 贡献者及开发者

「Privilege Menu」是开源软件。 以下人员对此插件做出了贡献。

贡献者

 *   [ FuzzGuard ](https://profiles.wordpress.org/fuzzguard/)

「Privilege Menu」插件已被翻译至 13 种本地化语言。 感谢[所有译者](https://translate.wordpress.org/projects/wp-plugins/privilege-menu/contributors)
为本插件所做的贡献。

[帮助将「Privilege Menu」翻译成简体中文。](https://translate.wordpress.org/projects/wp-plugins/privilege-menu)

### 对开发感兴趣吗?

您可以[浏览代码](https://plugins.trac.wordpress.org/browser/privilege-menu/)，查看
[SVN仓库](https://plugins.svn.wordpress.org/privilege-menu/)，或通过[RSS](https://plugins.trac.wordpress.org/log/privilege-menu/?limit=100&mode=stop_on_copy&format=rss)
订阅[开发日志](https://plugins.trac.wordpress.org/log/privilege-menu/)。

## 更新日志

#### 1.8.4

 * Added hook support for the hooks ‘priv_menu_roles’ and ‘priv_menu_visibility’.
   See FAQ on usage.

#### 1.8.3

 * Added extra line break between ‘User Restrictions’ and options to improve readability

#### 1.8.2

 * Moved ‘_priv_menu_role’ option string into ‘public $privMenuOption’ to allow 
   access from uninstall.php
 * Changed all references to ‘_priv_menu_role’ string to access $this->privMenuOption(
   For Conformity)
 * Fixed styling for text in widget admin panel
 * Fixed styling for text in widget admin panel in responsive mode.

#### 1.8.1

 * Tested with version 4.7 of WordPress

#### 1.8

 * Updated customWalker.php to match new navWalker code added to WordPress core
 * Tested with version 4.6 of WordPress
 * Upgraded TGM Plugin Activation class file version to 2.6.1

#### 1.7.4

 * Upgraded TGM Plugin Activation class file version to 2.6.0

#### 1.7.3

 * Added in backwards compatibility with old User Roles versions

#### 1.7.2

 * Removed erroneous recommended plugins. Should only recommend relevant plugins
   to “Privilege Menu”, such as “Privilege Widget”

#### 1.7.1

 * Upgraded TGM Plugin Activation class file version to 2.5.2

#### 1.7

 * Tested with version 4.5 of WordPress
 * Added TGM Plugin Activation code to recommend FuzzGuards other useful plugins

#### 1.6.1

 * Added uninstall file to remove all options from DB if plugin is removed.

#### 1.6

 * Added in ability to select menu display via User Role.
 * Removed ‘Admin Users” option – Replaced by “Logged In”, “Administrators” checkbox
 * Selecting logged in users now allows you to choose the Users Role

#### 1.5

 * Added Serbian Translation – Translated by: Ogi Djuraskovic (firstsiteguide.com)

#### 1.4

 * Added “lang” folder for localization files
 * Added French, German, Spanish and Chinese translations
 * Added .pot file for localization by others. Located in “lang” folder

#### 1.3

 * Added WordPress admin class protection coding to customWalker.php
 * Changed “Display Mode” to “User Restriction”
 * Added in bottom border to “User Restriction” area in each menu item to make the
   menu area easier to read

#### 1.2

 * Removed superfluous “2” from end of plugin name

#### 1.1

 * Changed “Both” to “All Users” in customWalker.php
 * Added in ability to show menu only to administrators

#### 1.0

 * Gold release

## 额外信息

 *  版本 **1.8.4**
 *  最后更新：**7 年前**
 *  活跃安装数量 **1,000+**
 *  WordPress 版本 ** 3.8 或更高版本 **
 *  已测试的最高版本为 **5.0.25**
 *  语言
 * [Albanian](https://sq.wordpress.org/plugins/privilege-menu/) 、 [Chinese (China)](https://cn.wordpress.org/plugins/privilege-menu/)、
   [Chinese (Taiwan)](https://tw.wordpress.org/plugins/privilege-menu/) 、 [English (Canada)](https://en-ca.wordpress.org/plugins/privilege-menu/)、
   [English (UK)](https://en-gb.wordpress.org/plugins/privilege-menu/) 、 [English (US)](https://wordpress.org/plugins/privilege-menu/)、
   [French (France)](https://fr.wordpress.org/plugins/privilege-menu/) 、 [German](https://de.wordpress.org/plugins/privilege-menu/)、
   [Italian](https://it.wordpress.org/plugins/privilege-menu/) 、 [Japanese](https://ja.wordpress.org/plugins/privilege-menu/)、
   [Romanian](https://ro.wordpress.org/plugins/privilege-menu/) 、 [Spanish (Chile)](https://cl.wordpress.org/plugins/privilege-menu/)、
   [Spanish (Spain)](https://es.wordpress.org/plugins/privilege-menu/) 和 [Swedish](https://sv.wordpress.org/plugins/privilege-menu/).
 *  [翻译成简体中文](https://translate.wordpress.org/projects/wp-plugins/privilege-menu)
 * 标签
 * [menu](https://cn.wordpress.org/plugins/tags/menu/)[menus](https://cn.wordpress.org/plugins/tags/menus/)
   [nav menu](https://cn.wordpress.org/plugins/tags/nav-menu/)[nav menus](https://cn.wordpress.org/plugins/tags/nav-menus/)
   [roles](https://cn.wordpress.org/plugins/tags/roles/)
 *  [高级视图](https://cn.wordpress.org/plugins/privilege-menu/advanced/)

## 评级

 5 星（最高 5 星）。

 *  [  7 条 5 星评价     ](https://wordpress.org/support/plugin/privilege-menu/reviews/?filter=5)
 *  [  0 条 4 星评价     ](https://wordpress.org/support/plugin/privilege-menu/reviews/?filter=4)
 *  [  0 条 3 星评价     ](https://wordpress.org/support/plugin/privilege-menu/reviews/?filter=3)
 *  [  0 条 2 星评价     ](https://wordpress.org/support/plugin/privilege-menu/reviews/?filter=2)
 *  [  0 条 1 星评价     ](https://wordpress.org/support/plugin/privilege-menu/reviews/?filter=1)

[Your review](https://wordpress.org/support/plugin/privilege-menu/reviews/#new-post)

[查看全部评论](https://wordpress.org/support/plugin/privilege-menu/reviews/)

## 贡献者

 *   [ FuzzGuard ](https://profiles.wordpress.org/fuzzguard/)

## 支持

有话要说吗？是否需要帮助？

 [查看支持论坛](https://wordpress.org/support/plugin/privilege-menu/)

## 捐助

您愿意支持这个插件的发展吗?

 [ 捐助此插件 ](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=G8SPGAVH8RTBU)