Hi there, I have a WP login issue, which I am trying to solve.
If a user, already logged in, returns to my front page and presses the domain/login link again, the user is directed to their WP dashboard.
Why is this happening, and how do I avoid this to happen, other than maybe hiding the login button for logged in users?
Regards
CarstenHi Carsten,
You don’t have to hide the login button. It is very easy to restrict users from vising dashboard.You may use something like this in your theme’s functions.php
/** * Protect dashboard access. */ function budddev_protect_dashboard() { // do not prevent ajax requests. if( defined( 'DOING_AJAX') ) { return; } $allowed_roles = array('administrator', 'editor'); // if user is not logged i // or does not have one of any of the allowed roles. // redirect. if ( ! is_user_logged_in() || ! array_intersect( wp_get_current_user()->roles, $allowed_roles ) ) { wp_safe_redirect( site_url('/') ); exit(0); } } add_action( 'admin_init', 'budddev_protect_dashboard' );
Regards
Brajesh
Viewing 4 posts - 1 through 4 (of 4 total)
The topic ‘Avoid members to enter their WP dashboard’ is closed to new replies.
This topic is: not resolved