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

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.