WordPress.org

Make WordPress Core

Ticket #37921: 37921.patch

File 37921.patch, 2.5 KB (added by johnjamesjacoby, 5 years ago)

Introduce user_invitation_endpoint() to ms-functions.php and use to replace newbloguser endpoint

  • src/wp-admin/user-new.php

    diff --git src/wp-admin/user-new.php src/wp-admin/user-new.php
    index bdd9921..54b9c86 100644
     
    7070                        add_existing_user_to_blog( array( 'user_id' => $user_id, 'role' => $_REQUEST[ 'role' ] ) );
    7171                        $redirect = add_query_arg( array( 'update' => 'addnoconfirmation' , 'user_id' => $user_id ), 'user-new.php' );
    7272                } else {
     73                        $endpoint    = user_invitation_endpoint();
    7374                        $newuser_key = substr( md5( $user_id ), 0, 5 );
    7475                        add_option( 'new_user_' . $newuser_key, array( 'user_id' => $user_id, 'email' => $user_details->user_email, 'role' => $_REQUEST[ 'role' ] ) );
    7576
     
    9596
    9697Please click the following link to confirm the invite:
    9798%4$s' );
    98                         wp_mail( $new_user_email, sprintf( __( '[%s] Joining confirmation' ), wp_specialchars_decode( get_option( 'blogname' ) ) ), sprintf( $message, get_option( 'blogname' ), home_url(), wp_specialchars_decode( translate_user_role( $role['name'] ) ), home_url( "/newbloguser/$newuser_key/" ) ) );
     99                        wp_mail( $new_user_email, sprintf( __( '[%s] Joining confirmation' ), wp_specialchars_decode( get_option( 'blogname' ) ) ), sprintf( $message, get_option( 'blogname' ), home_url(), wp_specialchars_decode( translate_user_role( $role['name'] ) ), home_url( "/{$endpoint}/{$newuser_key}/" ) ) );
    99100                        $redirect = add_query_arg( array('update' => 'add'), 'user-new.php' );
    100101                }
    101102        }
  • src/wp-includes/ms-functions.php

    diff --git src/wp-includes/ms-functions.php src/wp-includes/ms-functions.php
    index 0d97ea7..a286295 100644
     
    19331933}
    19341934
    19351935/**
     1936 * Filter & return the endpoint used for accepting invitations from existing
     1937 * users to existing sites.
     1938 *
     1939 * @since 4.7.0
     1940 *
     1941 * @return string
     1942 */
     1943function user_invitation_endpoint() {
     1944        /**
     1945         * Filter the endpoint segment used when accepting an invitation to a site
     1946         *
     1947         * @since 4.7.0
     1948         *
     1949         * @param string $segment Segment of URL immediately after the home_url()
     1950         */
     1951        return apply_filters( 'user_invitation_endpoint', 'newbloguser' );
     1952}
     1953
     1954/**
    19361955 * Add a new user to a blog by visiting /newbloguser/username/.
    19371956 *
    19381957 * This will only work when the user's details are saved as an option
     
    19421961 * @since MU
    19431962 */
    19441963function maybe_add_existing_user_to_blog() {
    1945         if ( false === strpos( $_SERVER[ 'REQUEST_URI' ], '/newbloguser/' ) )
     1964        $endpoint = user_invitation_endpoint();
     1965        if ( false === strpos( $_SERVER[ 'REQUEST_URI' ], "/{$endpoint}/" ) ) {
    19461966                return;
     1967        }
    19471968
    19481969        $parts = explode( '/', $_SERVER[ 'REQUEST_URI' ] );
    19491970        $key = array_pop( $parts );