WordPress禁止用户编辑个人资料

除了管理员以外,其他用户都不能编辑自己的个人资料:

  1. // ===== remove edit profile link from admin bar and side menu and kill profile page if not an admin
  2. if( !current_user_can(‘activate_plugins’) ) {
  3. function mytheme_admin_bar_render() {
  4. global $wp_admin_bar;
  5. $wp_admin_bar->remove_menu(‘edit-profile’, ‘user-actions’);
  6. }
  7. add_action( ‘wp_before_admin_bar_render’, ‘mytheme_admin_bar_render’ );
  8.  
  9. function stop_access_profile() {
  10. if(IS_PROFILE_PAGE === true) {
  11. wp_die( ‘Please contact your administrator to have your profile information changed.’ );
  12. }
  13. remove_menu_page( ‘profile.php’ );
  14. remove_submenu_page( ‘users.php’, ‘profile.php’ );
  15. }
  16. add_action( ‘admin_init’, ‘stop_access_profile’ );
  17. }

from: https://www.22vd.com/45180.html