I'm trying to allow the login (and wp dashboard access) to a specific user/admin by using this function but something is missing or I'm doing something wrong..

function redirect_non_specific_user() {
global $user_login;
$user_login = get_currentuserinfo();
if ( $user_login === 'myusername' ) {

} else {
    $logout_url = 'http://www.google.com/';
    wp_redirect( $logout_url, 302 );
add_action('get_header', 'redirect_non_specific_user');
  • 1
    Why don't you just set the users' roles to "No Role for This Blog"? – Andy Macaulay-Brook Mar 14 '19 at 15:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.