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

    (@kevinvess)

    Yes, add the following code to your theme’s functions.php to change your WordPress registration URL to point to your custom registration page:

    // Custom Registration URL
    function my_registration_page( $register_url ) {
        return site_url( '/custom-registration/', 'login' );
    }
    add_filter( 'register_url', 'my_registration_page', 10, 1 );

    Reference:
    https://github.com/WordPress/WordPress/blob/master/wp-includes/general-template.php#L368

    Also, if you’re using a custom login URL, add the following code to your theme’s functions.php to change your WordPress login URL to point to your custom login page:

    // Custom Login URL
    function my_login_page( $login_url, $redirect ) {
        return site_url( '/custom-login/?redirect_to=' . $redirect );
    }
    add_filter( 'login_url', 'my_login_page', 10, 2 );

    Reference:
    https://github.com/WordPress/WordPress/blob/master/wp-includes/general-template.php#L350

    • This reply was modified 7 years, 10 months ago by Kevin Vess.
    Thread Starter johnhorning-1

    (@johnhorning-1)

    Thanks!

    My form won’t redirect after logging in.

    When I visit
    dev.toys.com

    Force Login redirects to custom login page using Profile Builder plugin form
    dev.toys.com/login

    After clicking login button same page is loaded with this in url
    https://dev.toys.com/login/?redirect_to=http%3A%2F%2Fdev.toys.com%2Ftest%2F

    instead of going to the home of dev.toys.com/

    I used the code at the beginning of post to redirect login and registration.

    // Custom Login URL
    function my_login_page( $login_url, $redirect ) {
        return site_url( '/login/?redirect_to=' . $redirect );
    }
    add_filter( 'login_url', 'my_login_page', 10, 2 );
    
    // Custom Registration URL
    function my_registration_page( $register_url ) {
        return site_url( '/register/', 'login' );
    }
    add_filter( 'register_url', 'my_registration_page', 10, 1 );

    Do I have to change anything else in this code?

    Any chance of resolving the problems raised? I actually have the same problem and opened a new thread. This solution doesn’t work for me and it seems nor, for at least some, others.

    I wonder if its a multisite thing, because I found the login redirect had the same failure.

    Plugin Author Kevin Vess

    (@kevinvess)

    @yfig

    I think the problem is your “custom login page” is using an established WordPress login URL that redirects to the login page.

    I believe you need to create a unique URL for your custom login page or replace that WordPress function with your own to remove the redirect for that URL.

    @patbell101

    I believe I’ve answered your question on another post, but I’m adding my suggested fix here as well.

    My original suggestion on this post only really helps with fixing the wp_registration_url() function –?which I’m not using to whitelist the registration url.

    For now, you will need to also whitelist your custom registration URL using the v_forcelogin_whitelist filter:

    /**
     * Filter Force Login to allow exceptions for specific URLs.
     *
     * @return array An array of URLs. Must be absolute.
     */
    function my_forcelogin_whitelist( $whitelist ) {
      $whitelist[] = wp_registration_url();
      return $whitelist;
    }
    add_filter('v_forcelogin_whitelist', 'my_forcelogin_whitelist', 10, 1);
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Use with custom registration page?’ is closed to new replies.