Wordpress 删除“;简介;管理面板中的管理菜单

Wordpress 删除“;简介;管理面板中的管理菜单,wordpress,Wordpress,我正在使用WordPress,我想完全删除“配置文件”菜单选项 任何人都不知道我怎样才能做到这一点 谢谢,插件在订阅者级别上做到了这一点。 如果您希望为其他组执行此操作,您可能应该将其与plugin结合使用。plugin在订户级别执行此操作。 如果您希望为其他组执行此操作,您可能应该将其与插件结合使用。为了完整起见,下面介绍如何以编程方式执行此操作 // Run the function on admin_init add_action('admin_init', 'remove_profile

我正在使用WordPress,我想完全删除“配置文件”菜单选项

任何人都不知道我怎样才能做到这一点

谢谢,插件在订阅者级别上做到了这一点。 如果您希望为其他组执行此操作,您可能应该将其与plugin结合使用。

plugin在订户级别执行此操作。
如果您希望为其他组执行此操作,您可能应该将其与插件结合使用。

为了完整起见,下面介绍如何以编程方式执行此操作

// Run the function on admin_init
add_action('admin_init', 'remove_profile_menu');

// Removal function
function remove_profile_menu() {
  global $wp_roles;

  // Remove the menu. Syntax is `remove_submenu_page($menu_slug, $submenu_slug)`
  remove_submenu_page('users.php', 'profile.php');

  /* Remove the capability altogether. Syntax is `remove_cap($role, $capability)`
   * 'Read' is the only capability subscriber has by default, and allows access
   * to the Dashboard and Profile page. You can also remove from a specific user
   * like this:
   * $user = new WP_User(null, $username);
   * $user->remove_cap($capability); 
   */
  $wp_roles->remove_cap('subscriber', 'read');
}

为了完整性起见,以下是如何以编程方式执行此操作

// Run the function on admin_init
add_action('admin_init', 'remove_profile_menu');

// Removal function
function remove_profile_menu() {
  global $wp_roles;

  // Remove the menu. Syntax is `remove_submenu_page($menu_slug, $submenu_slug)`
  remove_submenu_page('users.php', 'profile.php');

  /* Remove the capability altogether. Syntax is `remove_cap($role, $capability)`
   * 'Read' is the only capability subscriber has by default, and allows access
   * to the Dashboard and Profile page. You can also remove from a specific user
   * like this:
   * $user = new WP_User(null, $username);
   * $user->remove_cap($capability); 
   */
  $wp_roles->remove_cap('subscriber', 'read');
}

我知道这已经晚了,但我只是偶然发现了这一点,并认为我会增加它。这会删除子菜单配置文件菜单项,但不会删除菜单配置文件项。对于像我这样创建了完全自定义的profile页面的人,我根本不希望我的用户访问profile.php页面。因此,此代码将用于:

function remove_profile_menu() {

    remove_submenu_page('users.php', 'profile.php');
    remove_menu_page('profile.php');
}

add_action('admin_menu', 'remove_profile_menu');
如果您只想为某些功能执行此操作,请使用以下代码:

function remove_profile_menu() {

    // Only the Admin can see the profile menu
    if(!current_user_can('update_core')) {

    remove_submenu_page('users.php', 'profile.php');
    remove_menu_page('profile.php');

    }
}

add_action('admin_menu', 'remove_profile_menu');

您可以使用current_user_can()函数来确定要查看菜单项的用户。

我知道这已经晚了,但我只是偶然发现了这一点,并认为我会添加到其中。这会删除子菜单配置文件菜单项,但不会删除菜单配置文件项。对于像我这样创建了完全自定义的profile页面的人,我根本不希望我的用户访问profile.php页面。因此,此代码将用于:

function remove_profile_menu() {

    remove_submenu_page('users.php', 'profile.php');
    remove_menu_page('profile.php');
}

add_action('admin_menu', 'remove_profile_menu');
如果您只想为某些功能执行此操作,请使用以下代码:

function remove_profile_menu() {

    // Only the Admin can see the profile menu
    if(!current_user_can('update_core')) {

    remove_submenu_page('users.php', 'profile.php');
    remove_menu_page('profile.php');

    }
}

add_action('admin_menu', 'remove_profile_menu');

您可以使用current_user_can()函数来确定要查看菜单项的用户。

这将完全删除对管理员的访问权限,而OP不一定希望这样。这将完全删除对管理员的访问权限,这并不一定是OP想要的。只是学到了一些新的东西…使用admin_init操作会在您的站点中导致一些ajax错误,因为还没有调用菜单。因此,改用这个动作:添加动作(“管理菜单”、“删除配置文件菜单”);刚刚学到了一些新的东西…使用admin_init操作会在您的站点中导致一些ajax错误,因为尚未调用菜单。因此,改用这个动作:添加动作(“管理菜单”、“删除配置文件菜单”);