Skip to content Skip to main navigation Skip to footer

Redirect Logged Users to Admin Path with Hide My WP Ghost

To redirect the logged users to admin when accessing the custom login path you can use the following hook code:

add_action('hmwp_login_init',function(){
   global $current_user;
   if (isset($current_user->ID)){
      wp_redirect(admin_url());
      exit;
    }
});

Add the code at the end of the wp-config.php file or in the theme’s functions.php file.

Result! Once you access the custom login path, if you are already logged in, the page will redirect to the admin dashboard.