Support » Plugin: Force Login » Custom Login Url with plain permalink format

  • Resolved fud

    (@fud)


    Hello,

    I am having troubles getting the custom login url to work. This is what I have so far:

    //Custom Login URL
    function my_login_page( $login_url, $redirect ) {
    return site_url( ‘/?page_id=2487’);
    }
    add_filter( ‘login_url’, ‘my_login_page’, 10, 2 );

    For some reason, when the question mark is after the slash, Force Login seems to break. When the question mark is not there, so it looks like :

    return site_url( ‘/page_id=2487’);

    Force login will try to direct me to this url : mydomain.com/page_id=2487, which doesn’t work.

    Thanks!

    https://wordpress.org/plugins/wp-force-login/

Viewing 6 replies - 1 through 6 (of 6 total)
  • I think this may be an Auth0 problem actually. I currently have the Auth0 plugin installed, which takes over the WordPress login..

    Plugin Author Kevin Vess

    (@kevinvess)

    I suspect this isn’t working because you’re using a query string ?page_id= as the custom login URL. Are you not able to configure a mod_rewrite to use a “pretty permalink?”
    https://codex.wordpress.org/Using_Permalinks

    And since Force Login is using the builtin WordPress function wp_login_url( $redirect ) to get the login URL to redirect to – while also passing a $redirect URL for after a successful login – it might be having trouble appending a second query string to the login URL for the after login $redirect URL.

    Have you tried using the get_permalink() function instead of the site_url() function to specify your custom login URL?

    //Custom Login URL
    function my_login_page( $login_url, $redirect ) {
        return get_permalink( 2487 );
    }
    add_filter( 'login_url', 'my_login_page', 10, 2 );

    Otherwise, I suggest using mod_rewrite and your .htaccess file to create a custom login URL that works without the ?page_id= query string.

    Hmm, so we tried to use get_permalink, and actually for both ways, if I try to just access mydomain.com/wp-login.php it will redirect me to my custom url.

    The problem is that if I try accessing a blocked page directly, Force Login seems to break so I’m not directed to a login page. I think the problem with using mod_rewrite and .htaccess is that I’m using mydomain.com/wp-login.php?wle to login to my admin dashboard since I have the Auth0 plugin installed.

    Plugin Author Kevin Vess

    (@kevinvess)

    The problem is that if I try accessing a blocked page directly, Force Login seems to break so I’m not directed to a login page.

    Can you be more specific about what is happening? Are you getting a PHP error – if so, what does it say? What exactly is happening when it “breaks?”

    If you disable the Auth0 plugin, does everything work as expected? If so, then yes – the issue is caused by a conflict with that plugin.

    Sorry, when I said breaks, I meant that I was able to access the page without having to login.

    Nevermind, I just configured some Auth0 stuff, so I got it working.

    Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Custom Login Url with plain permalink format’ is closed to new replies.