Skip to contentSkip to main navigation Skip to footer

Redirect Logged Users to Admin Dashboard

If you are using a custom login path for your WordPress website and want to automatically redirect logged users to the admin dashboard, you can use a hook code.

Here is how you can do it:

  1. Open the wp-config.php file or your theme’s functions.php file.
  2. Add the following hook code at the end of the file:
add_action('hmwp_login_init',function(){
   global $current_user;
   if (isset($current_user->ID)){
      wp_redirect(admin_url());
      exit;
    }
});

Save the changes and upload the file to your server.

Once you have added the hook code, any logged-in user accessing the custom login path will be automatically redirected to the admin dashboard. This can be a useful feature for your users and can save them time and effort.


Using a WordPress Plugin

Alternatively, if you are using the Hide My WP Ghost plugin, you can use the built-in option to redirect logged users to the admin dashboard. Here is how you can do it:

  1. Install and activate the Hide My WP Ghost plugin on your WordPress website.
  2. Go to Hide My WP > Tweaks in the WordPress dashboard menu.
  3. Click on the “Redirects” tab.
  4. Check the box next to “Redirect Logged Users to Dashboard”.
  5. Save the changes.

Once you have activated the option, any logged-in user accessing the custom login path will be automatically redirected to the admin dashboard.

That’s it! You have now learned how to redirect logged users to the admin dashboard when using a custom login path on your WordPress website.