2

I am trying to restrict access to wp-admin: only administrators and editors should be able to access it. At the moment I am using this function:

function restrict_admin(){
//if not administrator, kill WordPress execution and provide a message
    if ( ! current_user_can( 'manage_options' ) ) {
        wp_die( __('You are not allowed to access this part of the site') );
    }
}
add_action( 'admin_init', 'restrict_admin', 1 );

But this does the job only for administrator, editors are not allowed to access this part of the site. What can I do?

3
  • What is different from the default behavior of Wordpress and what you want to implement exactly
    – Ramhound
    May 9, 2013 at 13:07
  • I want that editors could view information from wp-admin, but not having permission to change it.
    – user2358350
    May 9, 2013 at 13:11
  • Seems like the default permission system built-into Wordpress should handle a situation like this. There already is a tested and proven plug-in that allows you adjust the roles: wordpress.org/support/plugin/user-role-editor and a description of the default roles: en.support.wordpress.com/user-roles/#changing-user-roles just took my until now to realize you didn't write the code you posted. You can also add new roles: wordpress.org/extend/plugins/members and efine the exact permissins you want.
    – Ramhound
    May 9, 2013 at 13:32

0