限制某些用户对wp admin的访问
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了限制某些用户对wp admin的访问相关的知识,希望对你有一定的参考价值。
Adding this snippet to the functions.php of your wordpress theme will restrict wp-admin access to certain users as defined athttp://codex.wordpress.org/Roles_and_Capabilities
And also still allows for user access to admin-ajax.php , async-upload.php .
function restrict_access_admin_panel(){ global $current_user; get_currentuserinfo(); if ( // Look for the presence of /wp-admin/ in the url && // Allow calls to async-upload.php && // Allow calls to admin-ajax.php ) { // Does the current user fail the required capability level? if (!current_user_can('activate_plugins')) { wp_redirect( get_bloginfo('url') ); exit; } } } add_action('admin_init', 'restrict_access_admin_panel', 1);
以上是关于限制某些用户对wp admin的访问的主要内容,如果未能解决你的问题,请参考以下文章
WordPress:具有自定义角色的用户无法访问 wp-admin