bbp_search_results_redirect()

Redirect to search results page if needed

Description

Return

(If) a redirect is not needed

Source

File: bp-forums/search/functions.php

62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
function bbp_search_results_redirect() {
    global $wp_rewrite;
     
    // Bail if not a search request action
    if ( empty( $_GET['action'] ) || ( 'bbp-search-request' !== $_GET['action'] ) ) {
        return;
    }
 
    // Bail if not using pretty permalinks
    if ( ! $wp_rewrite->using_permalinks() ) {
        return;
    }
 
    // Get the redirect URL
    $redirect_to = bbp_get_search_results_url();
    if ( empty( $redirect_to ) ) {
        return;
    }
 
    // Redirect and bail
    wp_safe_redirect( $redirect_to );
    exit();
}

Changelog

Changelog
Version Description
bbPress (r4928) Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.