• Resolved hpb1980

    (@hpb1980)


    Hi, I changed the login slug to something other than the ‘wp-admin’. Right now this is what happens: I login (as the administrator) and I get redirected to the homepage and I again need to manually enter the wordpress dashboard URL to get there. However when anyone logs in I want them to go the the wordpress dashboard (wp-admin).

    Here is the code that I found in the WordPress Codex that lets me redirect folks to the backend page after they login:

    add_filter( 'login_redirect', create_function( '$url,$query,$user', 'return admin_url();' ), 10, 3 );

    I’ve just changed the “return home_url();” to “return admin_url();”. However, this does not work and I’m still being redirected to the homepage after login. What am I doing wrong here?

    https://www.ads-software.com/plugins/better-wp-security/

Viewing 11 replies - 1 through 11 (of 11 total)
  • @hp1980

    Please help me understand this a little bit better because I fail to see why this is an iTSec plugin issue.

    Does this redirect to home after login behavior change when you disable the Hide Backend feature or even entirely disable the iTSec plugin ?

    dwinden

    Thread Starter hpb1980

    (@hpb1980)

    Yep. If I enable the hide login admin feature, I get redirected to the home page. If I disable the Hide Login Admin feature, I go back to the default wordpress admin login redirect behavior, which is going directly to the dashboard instead of the homepage. Have not tried disabling the plugin entirely but I’m guessing since it goes back to the default behavior when I disable the feature, it should definitely happen if I disable the plugin.

    @hpb1980

    Weird non default behavior … interesting case …

    Let’s say the iTSec plugin Hide Backend feature is disabled.

    Which URL do you manually type in into the browser address bar to access the WP Dashboard login screen ? (So I’m not asking for the URL you might automatically get redirected to after pressing the ENTER key …).
    It might be you are instead using a favorite\saved link. In that case how does the URL of that favorite/URL link look like ?

    Is it: https://www.domain.com/wp-admin ?
    Or is it: https://www.domain.com/wp-login.php ?
    Or a different URL ? If so how does that URL look like ?

    If you are normally not using the URL https://www.domain.com/wp-login.php to log into WP Dashboard try it and see what happens. (While the iTSec plugin Hide Backend feature is still disabled …) There is a slight possibility that logging in using this link will also redirect you to the home page after login. I want this tested to rule this out.

    It may seem like the iTSec plugin Hide Backend feature is causing the home page redirect but there is also a chance that it simply reveals an issue that has always been there … you just never noticed it because of the WP Dashboard login URL you normally use …
    Anyway we need to rule this out before we can proceed …

    dwinden

    Thread Starter hpb1980

    (@hpb1980)

    Let’s say the iTSec plugin Hide Backend feature is disabled.

    Which URL do you manually type in into the browser address bar to access the WP Dashboard login screen ? (So I’m not asking for the URL you might automatically get redirected to after pressing the ENTER key …).
    It might be you are instead using a favorite\saved link. In that case how does the URL of that favorite/URL link look like ?

    In the address bar I enter – subdomain.domain.com/wp-admin. However, this redirects to wp-login.php?redirect_to=http%3A%2F%2Fsubdomain.domain.com%2Fwp-admin%2F&reauth=1

    If you are normally not using the URL https://www.domain.com/wp-login.php to log into WP Dashboard try it and see what happens. (While the iTSec plugin Hide Backend feature is still disabled …) There is a slight possibility that logging in using this link will also redirect you to the home page after login. I want this tested to rule this out.

    Interesting. When I enter wp-login.php it still shows me the login page and when the login completes it takes me to the home page and not the backend dashboard.

    @hpb1980

    Ok, great. This proves the issue is not caused by the iTSec plugin Hide Backend feature.

    You have been comparing the result of (Hide Backend disabled):

    https://subdomain.domain.com/wp-login.php?redirect_to=http%3A%2F%2Fsubdomain.domain.com%2Fwp-admin%2F&reauth=1

    with the result of (Hide Backend enabled):

    https://subdomain.domain.com/secretslug

    While you should be comparing the result of (Hide Backend disabled):

    https://subdomain.domain.com/wp-login.php?redirect_to=http%3A%2F%2Fsubdomain.domain.com%2Fwp-admin%2F&reauth=1

    with the result of (Hide Backend enabled):

    https://subdomain.domain.com/secretslug?redirect_to=http%3A%2F%2Fsubdomain.domain.com%2Fwp-admin%2F&reauth=1

    Enable the Hide Backend feature and test:

    https://subdomain.domain.com/secretslug?redirect_to=http%3A%2F%2Fsubdomain.domain.com%2Fwp-admin%2F&reauth=1

    It should work fine.

    In short if there is no redirect_to parameter provided in the URL there is some piece of code somewhere (active theme, active theme functions.php file or other plugin than the iTSec plugin) that is responsible for redirecting to the home page after login.

    If you want to get the simplest URL to work (Hide Backend enabled):

    https://subdomain.domain.com/secretslug

    you will need to track down the piece of code responsible for redirecting to the home page after login.
    That will also solve the issue for URL https://subdomain.domain.com/wp-login.php while Hide Backend is disabled.

    dwinden

    Thread Starter hpb1980

    (@hpb1980)

    Thanks @dwinden.

    Quick question: How do I test the “?redirect_to=…” after the secret slug? I tried putting it with the secret slug in the space for “Login slug” but it just stripped out the special characters such as the question marks and forward slashes and treated all the other characters as the slug. With the “hide login admin” featured disabled, I’d enter /wp-admin and it would automatically redirect to “wp-login.php?redirect_to=…”

    Thread Starter hpb1980

    (@hpb1980)

    Also is there a reference guide for using the “action” variable with the iTSec plugin?

    @hpb1980

    No need to change the Hide Backend slug in the iTSec plugin. Leave it as it was.

    You can simply type in the entire URL in the browser address bar.
    (Its not a practical URL because you don’t want to keep typing in such complicated URL. Remember this is only for testing. I just want you to see that this URL actually works and that it will redirect to the Dashboard after login …)

    This URL actually works because of the Hide Backend RewriteRule added to the .htaccess file …
    The Hide Backend secret login slug does not have an automatic URL rewrite
    mechanism like wp-admin.

    Ultimately you want the URL with just the Hide Backend slug in it to work.
    (https://subdomain.domain.com/secretslug)
    But again that will require to identify the piece of code which is responsible for the redirect to the home page after login. And once identified you’ll need to disable that piece of code …

    dwinden

    @hpb1980

    About the “action” variable.
    I’m unaware of any printed reference guide, but it is explained in this (old) video tutorial about the iTSec plugin Hide Backend feature.

    dwinden

    @hpb1980

    If you require no further assistance please mark this topic as ‘resolved’.

    dwinden

    Thread Starter hpb1980

    (@hpb1980)

    My apologies on the delayed responses. I still have not figured out how to make this work. I’ll write back when I need more help. For the moment, this can be marked as resolved. Thanks again for everything.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Login redirect to the admin page’ is closed to new replies.