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;
        }
}

 

474 responses to “WordPress Dashboard block only for administrators

  1. bitcoincasino

    I’ve been looking for photos and articles on this topic over the past few days due to a school assignment, bitcoincasino and I’m really happy to find a post with the material I was looking for! I bookmark and will come often! Thanks 😀

  2. casino online

    I’ve been searching for hours on this topic and finally found your post. casino online, I have read your post and I am very impressed. We prefer your opinion and will visit this site frequently to refer to your opinion. When would you like to visit my site?

Deja una respuesta

Tu dirección de correo electrónico no será publicada.

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