WordPress Dashboard block only for administrators

When in WordPress, a user registers access to the Dashboard, although at first only access to the options that are allowed depending on the role that has assigned in many occasions we may be interested that they can not access, for this we must put the following code to our functions.php

add_action( 'init', 'blockusers_init' );

function blockusers_init() {
        if ( is_admin() && ! current_user_can( 'administrator' ) ) {
                wp_redirect( home_url() );
                exit;
        }
}

 

One Response to “WordPress Dashboard block only for administrators

  1. Pingback: fuck google

Comments are closed.

Rúa Pilar Miró n 6 Santiago de Compostela

Jersey St , Manchester, Greater Manchester M4 6JG, GB

T. 609 538 171 - 634 59 34 43

info@teslatechnologies.com