• Resolved spencern

    (@spencern)


    With the plugin enabled I get forced to the login screen at /wp-login.php correctly, but the redirect part of the url has port :10462 added to the hostname and fails to display. Original visit was to the default https url.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Kevin Vess

    (@kevinvess)

    Hi– thanks for using Force Login!

    It sounds like your web server is not using a standard port. Force Login appends the $_SERVER['SERVER_PORT'] to the redirect URL for those sites which aren’t using a standard port.

    However, you can filter the redirect URL using the v_forcelogin_redirect hook. Check out the FAQ for an example of this.

    Here is an (untested) example of how you might remove the port from your redirect URL:

    /**
     * Filter the URL to redirect to on login.
     *
     * @param string $url The visited URL.
     * @return string URL to redirect to on login. Must be absolute.
     */
    function my_forcelogin_redirect( $url ) {
      // check if port is included in the url
      if ( strpos( $url, ':' ) != false ) {
    
        // find and remove the port number
        $urlParts = parse_url( $url );
        unset( $urlParts['port'] );
    
        // rebuild the redirect url
        $url = implode( '', $urlParts );
      }
      return $url;
    }
    add_filter( 'v_forcelogin_redirect', 'my_forcelogin_redirect' );

    Thanks!

    Plugin Author Kevin Vess

    (@kevinvess)

    I just released a new version (v5.4) which might help with this issue.

    Thanks for using Force Login!

    Hello Kevin

    I added the following link to the whitelist but it doesn’t work.

    /**
    * Filter Force Login to allow exceptions for specific URLs.
    *
    * @param array $whitelist An array of URLs. Must be absolute.
    * @return array
    */
    function my_forcelogin_whitelist( $whitelist ) {
    $whitelist[] = home_url( ‘/https://language.course-online.ir/azar-97’ );
    $whitelist[] = home_url( ‘/2015/03/post-title/’ );
    return $whitelist;
    }
    add_filter( ‘v_forcelogin_whitelist’, ‘my_forcelogin_whitelist’ );

    I added the following link to the whitelist but it doesn’t work.

    /**
    * Filter Force Login to allow exceptions for specific URLs.
    *
    * @param array $whitelist An array of URLs. Must be absolute.
    * @return array
    */
    function my_forcelogin_whitelist( $whitelist ) {
    $whitelist[] = home_url( ‘/https://language.course-online.ir/azar-97’ );
    $whitelist[] = home_url( ‘/2015/03/post-title/’ );
    return $whitelist;
    }
    add_filter( ‘v_forcelogin_whitelist’, ‘my_forcelogin_whitelist’ );

    Plugin Author Kevin Vess

    (@kevinvess)

    @ahmadmy

    Please create a new support topic for your issues.

    The code you’re using is not formatted correctly, specifically the first URL in your $whitelist array.

    Use either of the following:

    $whitelist[] = 'https://language.course-online.ir/azar-97';

    OR

    $whitelist[] = home_url( '/azar-97' );

    Hello
    Thank you for your support.

    I added the following function to the whitelist but it didn’t work

    /**
    * Filter Force Login to allow exceptions for specific URLs.
    *
    * @param array $whitelist An array of URLs. Must be absolute.
    * @return array
    */
    function my_forcelogin_whitelist( $whitelist ) {
    $whitelist[] = ‘https://language.course-online.ir/azar-97’;

    return $whitelist;
    }
    add_filter( ‘v_forcelogin_whitelist’, ‘my_forcelogin_whitelist’ );

    Plugin Author Kevin Vess

    (@kevinvess)

    @ahmadmy

    Please create a new support topic for your issues.

    Again, the code you’re using is not formatted correctly. You’re missing a closing quote and you have an extra semicolon. It should be like this:

    $whitelist[] = 'https://language.course-online.ir/azar-97&#8217';

    Furthermore, you need to give more detail; explain what exactly you’re trying to achieve and why exactly it isn’t working.

    Is it not working because you’re getting errors? Or is it not allowing visitors to view the page you’re trying to whitelist?

    If language.course-online.ir your site URL,?then I recommend using the home_url( '/azar-97' ) function instead of hard-coding the full site URL.

    Good luck!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘redirect to a different port’ is closed to new replies.