How to prevent users to get to the admin panel?

6.24K viewsCore
0

Hi,

Everything needed is accessible in front-end (profile, post question, post answer, modify these…). By the way this website is not sending me to the admin panel after connexion nor to ask this question.

So I wonder why mine is doing it and if I have done anything wrong in the settings.

Many thanks in advancefor your help (eventually by mp?)

Sincerely,

Thierry

0

Thanks a lot Rahul,

The example suggested in the codex works too.

Unfortunately, none of these two solutions dont work on log out. I have followed the simple instructions found here and it makes it.

0

OOps,

Found a partial solution, adding this to functions.php:

/**
* Block access to admin panel (to everybody except admin)
*/

add_action( ‘init’, ‘blockusers_init’ );
function blockusers_init() {
if ( is_admin() && ! current_user_can( ‘administrator’ ) &&
! ( defined( ‘DOING_AJAX’ ) && DOING_AJAX ) ) {
wp_redirect( home_url() );
exit;
}
}

0

Hello,

Have a look at this link:

Login redirect