WordPress禁止用户编辑个人资料
以下代码由PHP站长网 52php.cn收集自互联网现在PHP站长网小编把它分享给大家,仅供参考 对于一个资深 wordpress 用户,各种奇葩的要求都会遇到,昨天群里有朋友就问如何禁止用户编辑他们的个人资料,是不是很奇怪的问题,那么下面分享一下相关方法。 禁止所有用户管理员也不能编辑自己的个人资料(貌似没必要),但是他可以编辑他人的个人资料: add_action( 'admin_init','stop_access_profile' ); function stop_access_profile() { remove_menu_page( 'profile.php' ); remove_submenu_page( 'users.php','profile.php' ); if(IS_PROFILE_PAGE === true) { wp_die( 'You are not permitted to change your own profile information. Please contact a member of HR to have your profile information changed.' ); } } 禁止非管理员除了管理员以外,其他用户都不能编辑自己的个人资料: // ===== remove edit profile link from admin bar and side menu and kill profile page if not an admin if( !current_user_can('activate_plugins') ) { function mytheme_admin_bar_render() { global $wp_admin_bar; $wp_admin_bar->remove_menu('edit-profile','user-actions'); } add_action( 'wp_before_admin_bar_render','mytheme_admin_bar_render' ); ? function stop_access_profile() { if(IS_PROFILE_PAGE === true) { wp_die( 'Please contact your administrator to have your profile information changed.' ); } remove_menu_page( 'profile.php' ); remove_submenu_page( 'users.php','profile.php' ); } add_action( 'admin_init','stop_access_profile' ); } 以上就是 WordPress 禁止用户编辑个人资料的相关代码,请根据自己的需要,修改 wp_die() 里面的提示内容,如果您有更好的方式不妨和我们分享一下。 以上内容由PHP站长网【52php.cn】收集整理供大家参考研究如果以上内容对您有帮助,欢迎收藏、点赞、推荐、分享。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |