Stop open wp-admin page

Hi, how can I set membership pro that user will not have access to the wordpress backend? I don't want the user to change the address in the browser to get access to the backend. thx.

kind regards Reinahrd

    Patrick

    Hi there FLYINGFOX

    I hop you're having a great day!

    By default, regular users on a WordPress site are registered with the Subscriber role. That role does not have access to anything in the wp-admin but their own profile.

    However, if you don't even want them to be able to access that, you can lock 'em out with a custom function added to your child-theme's functions.php file. This code will check if a user is attempting to access the admin area, and also check that the user does not have a capability that only admins have. If anyone but an admin tries, they'll get bumped to the front-page of your site.

    //Keep all users out of wp-admin
    add_action( 'init', 'blockusers_init' );
    function blockusers_init() {
    if ( is_admin() && ! current_user_can( 'activate_plugins' ) &&
    ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
    wp_redirect( home_url() );
    exit;
    }
    }