// 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');
}
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');
3条答案
按热度按时间aor9mmx11#
为了完整起见,下面介绍如何通过编程方式完成此操作...
webghufk2#
我知道这是晚了,但我只是偶然发现这个,并认为我会添加到它。这确实删除了子菜单配置文件菜单项,但没有删除菜单配置文件项。对于像我这样创建了一个完全自定义的配置文件页面的人,我不希望我的用户访问profile.php页面。所以下面的代码将工作:
如果您只想对某些功能执行此操作....请使用以下代码:
您可以使用current_user_can()函数来确定您希望哪些人查看菜单项。
yh2wf1be3#
Profiless插件可以在用户级别上实现这个功能。如果你想在其他组中实现这个功能,你应该将它与Capability manager插件结合使用。