Making WordPress.org

Changeset 9489


Ignore:
Timestamp:
02/11/2020 06:00:12 AM (7 years ago)
Author:
dd32
Message:

Support Forums: Add a redirect for an old form of bbPress user profile pages.

Fixes #4806.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-hooks.php

    r9487 r9489  
    1818                add_filter( 'old_slug_redirect_post_id',       array( $this, 'disable_wp_old_slug_redirect' ) );
    1919                add_action( 'template_redirect',               array( $this, 'redirect_update_php_page' ) );
     20                add_action( 'template_redirect',               array( $this, 'redirect_legacy_user_structure' ) );
    2021                add_filter( 'wp_insert_post_data',             array( $this, 'set_post_date_gmt_for_pending_posts' ) );
    2122                add_action( 'wp_print_footer_scripts',         array( $this, 'replace_quicktags_blockquote_button' ) );
     
    258259                        wp_redirect( home_url( '/update-php/' ), 301 );
    259260                        exit;
     261                }
     262        }
     263
     264        /**
     265         * Redirect /users/$id to their new /users/$slug permastructure.
     266         */
     267        public function redirect_legacy_user_structure() {
     268                if ( is_404() && get_query_var( 'bbp_user' ) && is_numeric( get_query_var( 'bbp_user' ) ) ) {
     269                        $user = get_user_by( 'id', (int) get_query_var( 'bbp_user' ) );
     270                        if ( $user ) {
     271                                wp_redirect( home_url( '/users/' . $user->user_nicename . '/' ), 301 );
     272                                exit;
     273                        }
    260274                }
    261275        }
Note: See TracChangeset for help on using the changeset viewer.