Advertisement
miriamdepaula

WordPress: Disallow users edit its own profile

May 24th, 2012
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.63 KB | None | 0 0
  1. <?php
  2. //Disallow users edit its own profile
  3.  
  4. if( !current_user_can('activate_plugins') ) {
  5.   function mytheme_admin_bar_render() {
  6.       global $wp_admin_bar;
  7.       $wp_admin_bar->remove_menu('edit-profile', 'user-actions');
  8.   }
  9.   add_action( 'wp_before_admin_bar_render', 'mytheme_admin_bar_render' );
  10.  
  11.   function stop_access_profile() {
  12.       if(IS_PROFILE_PAGE === true) {
  13.           wp_die( 'Please contact your administrator to have your profile information changed.' );
  14.       }
  15.       remove_menu_page( 'profile.php' );
  16.       remove_submenu_page( 'users.php', 'profile.php' );
  17.   }
  18.   add_action( 'admin_init', 'stop_access_profile' );
  19. }
  20.  
  21.  
  22. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement