/ Published in: PHP

Adding this snippet to the functions.php of your wordpress theme will restrict wp-admin access to certain users as defined at
http://codex.wordpress.org/Roles_and_Capabilities
And also still allows for user access to admin-ajax.php , async-upload.php .
http://codex.wordpress.org/Roles_and_Capabilities
And also still allows for user access to admin-ajax.php , async-upload.php .
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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);
Comments
