WordPress.org

Ready to get started?Download WordPress

Forums

HC Custom WP-Admin URL
[resolved] Users directed to admin section instead of site (5 posts)

  1. MaxWendkos
    Member
    Posted 1 year ago #

    Hey there, need help with one more issue I'm having.

    When a user logs in, she's being directed to the WP-admin panel instead of the website itself. All of my site's users are just subscribers and there's no reason for them to ever see the WP-admin panel at all. Is there a way for me to have the log-in page direct to the domain instead of the wp-admin panel? (I'd like WP-admin to only be accessible when a user is logged into and enters domain.com/wp-admin into the URL bar.)

    http://wordpress.org/extend/plugins/hc-custom-wp-admin-url/

  2. Some Web Media
    Member
    Plugin Author

    Posted 1 year ago #

    As far as I know, its by WP default to redirect to dashboard after loging in from wp-login.php

    Try this:

    function redirect_users() {
        // retrieve current user info
        global $current_user;
        get_currentuserinfo();
    
        // If login user role is Subscriber
        if ($current_user->user_level == 0) {
    	wp_redirect(home_url());
    	exit;
        }
    }
    add_action('admin_init', 'redirect_users');

    Be aware that domain.com/wp-admin will not be accessible when using our plugin, because its sole purpose is to hide that url from possible hackers. You have to use new url you created for logging in.

    So with the solution above, you'll be able to redirect subscribers to home and let admins to dashboard.

    Hope this solves your problem.

  3. MaxWendkos
    Member
    Posted 1 year ago #

    domain.com/wp-admin has still been working for me even with your plugin installed. Currently:

    • When a user is logged in, domain.com directs her to the website and domain.com/wp-admin directs her to the dashboard.
    • When a user is logged out, domain.com and domain.com/wp-admin both direct her to domain.com/customer-slug (where she can log in).
    • When a subscriber logs in, she is directed to domain.com/wp-admin/profile.php.
    • When an admin logs in, she is directed to domain.com/wp-admin.

    From what you've said, sounds like that means the plugin isn't working how you intended it to. (Perhaps this was caused by the changes we made to the Basic Authentication code a couple days ago?)

    As for the code, where should I put it? I'm working with a child theme.

  4. Some Web Media
    Member
    Plugin Author

    Posted 1 year ago #

    The plugin is working perfectly, but as in the first case, its interfering with "Basic Authentication" plugin which is responsible for redirects.

    If you just want to redirect subscribers to home after login, just put the code I've provided to functions.php and it should work.

    The thing is that our plugin is for security purposes only, and as I understood it, you just want to change the url of the wp-login. So yeah it will work for you, but there could be much easier solution just to write function that rewrites the wp-admin url without any security checking.

  5. MaxWendkos
    Member
    Posted 1 year ago #

    Got it. I meant to say that the plugin wasn't working as you'd intended it to for me (because of the Basic Authentication conflict), not in general.

    I copied your instructions and they did fix the re-direct issue. Thank you.

    Also, while I did want to change the wp-login, I am also interested in the security as well.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.