bp_do_404( string $redirect = 'remove_canonical_direct' )

Trigger a 404.

Description

Parameters

$redirect

(Optional) If 'remove_canonical_direct', remove WordPress' "helpful" redirect_canonical action. Default: 'remove_canonical_redirect'.

Default value: 'remove_canonical_direct'

Source

File: bp-core/bp-core-functions.php

2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
function bp_do_404( $redirect = 'remove_canonical_direct' ) {
    global $wp_query;
 
    /**
     * Fires inside the triggering of a 404.
     *
     * @since BuddyPress 1.5.0
     *
     * @param string $redirect Redirect type used to determine if redirect_canonical
     *                         function should be be removed.
     */
    do_action( 'bp_do_404', $redirect );
 
    $wp_query->set_404();
    status_header( 404 );
    nocache_headers();
 
    if ( 'remove_canonical_direct' === $redirect ) {
        remove_action( 'template_redirect', 'redirect_canonical' );
    }
}

Changelog

Changelog
Version Description
BuddyPress 1.5.0 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.