Developers

Redirect Logged Users to Admin Dashboard

Redirect Logged Users with WP Ghost

If you are using the 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. Go to WP Ghost > Tweaks > Redirects.
  2. Switch on the Redirects Logged Users To Dashboard option to automatically redirect users to the WordPress dashboard when they are logged in.
  3. Click the Save button to apply 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.

Redirect Logged Users with Code

Alternatively, you can use a hook code if you use a custom login path for your WordPress website and want to automatically redirect logged-in users to the admin dashboard.

Here is how you can do it:

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 or the path you set in the code. This can be a helpful feature for your users and save them time and effort.

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

John Darrel

Change Database Prefix in WordPress

Because hackers often use bots to search for security flaws in your website, it is…

12 months

Customize WordPress Uploads Directory

The easiest way to change the default media uploads path is to use the WP…

12 months

WP Ghost and WP Rocket Cache

To hide all CSS and JS you need to follow the steps to Combine the…

12 months

Why is website security important?

https://youtu.be/6ylhojSi-_E In this video, we’ll explore why website security matters and what can happen if…

12 months

Is WordPress Website Easily Hacked?

The security of your WordPress site depends on multiple factors, such as the strength of…

12 months

Setting up Two-Factor Authentication (2FA) for WordPress Using Mobile Apps

When you enable two-factor authentication (2FA) for your WordPress website, it adds an extra layer…

12 months