Hide dashboard from none admin WordPress registered users
By default, WordPress grants limited dashboard access to all registered users. Once logged in successfully they are redirected automatically to the dashboard.
In most cases, you would prefer to redirect users to a specific page on your website keeping them away from the backend. The following code snippet comes in handy to redirect users who do not have ‘administrator’ privileges to whichever page you want.
As you can see, the snippet uses the current_user_can(‘administrator’) WordPress function to check if the logged in user is an admin. If the user isn’t admin it calls another function wp_redirect(home_url()) which takes care of redirecting the user to the home page.
You can customize both functions to suit your needs. You can find more information about the WordPress redirection function here. You can also find more details about the current_user_can() on this page. So just give it a try and tweak it to your preferences.
The code is straightforward. Just give it a try and tweak it to your preferences.