Skip to content

Instantly share code, notes, and snippets.

@fillipetech
Created June 5, 2019 18:43
Show Gist options
  • Select an option

  • Save fillipetech/234f298b5d959a32011471bbac590f86 to your computer and use it in GitHub Desktop.

Select an option

Save fillipetech/234f298b5d959a32011471bbac590f86 to your computer and use it in GitHub Desktop.
// 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');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment