Making WordPress.org


Ignore:
Timestamp:
10/05/2016 11:29:13 AM (10 years ago)
Author:
ocean90
Message:

WordPress.org SSO: Filter register URL and login post URL to use login.wordpress.org.

Also make sure that lost password URL uses login.wordpress.org.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/common/includes/wporg-sso/wp-plugin.php

    r4120 r4189  
    6060                        add_filter( 'allowed_redirect_hosts', array( &$this, 'add_allowed_redirect_host' ) );
    6161
    62                         // Replace the lost password URL by our own
    63                         add_filter( 'lostpassword_url', array( &$this, 'lostpassword_url' ), 10, 2 );
     62                        // Replace some URLs by our own.
     63                        add_filter( 'lostpassword_url', array( &$this, 'lostpassword_url' ), 20, 2 );
     64                        add_filter( 'site_url', array( $this, 'login_post_url' ), 20, 3 );
     65                        add_filter( 'register_url', array( $this, 'register_url' ), 20 );
    6466
    6567                        if ( preg_match( '!/wp-signup\.php$!', $this->script ) ) {
    … …  
    8688                                } else {
    8789                                        // Otherwise, filter the login_url to point to the SSO
    88                                         add_action( 'login_url', array( &$this, 'login_url' ), 10, 2 );
     90                                        add_filter( 'login_url', array( $this, 'login_url' ), 20, 2 );
    8991                                }
    9092
    … …  
    163165                }
    164166
     167                /**
     168                 * Filters the default login lost URL and returns our custom one instead.
     169                 *
     170                 * @param string      $url     The complete site URL including scheme and path.
     171                 * @param string      $path    Path relative to the site URL. Blank string if no path is specified.
     172                 * @param string|null $scheme  Site URL context.
     173                 * @return string
     174                 */
     175                public function login_post_url( $url, $path, $scheme ) {
     176                        if ( 'login_post' === $scheme ) {
     177                                return $this->sso_host_url . '/wp-login.php';
     178                        }
     179
     180                        return $url;
     181                }
     182
     183                /**
     184                 * Filters the default registration URL and returns our custom one instead.
     185                 *
     186                 * @return string
     187                 */
     188                public function register_url() {
     189                        return $this->sso_signup_url;
     190                }
    165191
    166192                /**
    … …  
    186212                 */
    187213                public function lostpassword_url( $lostpassword_url, $redirect ) {
    188                         return home_url( $this->valid_sso_paths['lostpassword'] . '/?redirect_to=' . $redirect );
     214                        return $this->sso_host_url . $this->valid_sso_paths['lostpassword'] . '/?redirect_to=' . $redirect;
    189215                }
    190216
Note: See TracChangeset for help on using the changeset viewer.