bp_do_404

Trigger a 404.

Description

bp_do_404( (string) $redirect = 'remove_canonical_direct' ); 

Parameters (1)

0. $redirect — Optional. (string) => 'remove_canonical_direct'
If remove_canonical_direct,, remove WordPress' helpful redirect_canonical action. Default: remove_canonical_redirect..

Usage

  1. if ( !function_exists( 'bp_do_404' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-core/bp-core-functions.php'; 
  3.  
  4. // If 'remove_canonical_direct', remove WordPress' "helpful" 
  5. // redirect_canonical action. Default: 'remove_canonical_redirect'. 
  6. $redirect = 'remove_canonical_direct'; 
  7.  
  8. // NOTICE! Understand what this does before running. 
  9. $result = bp_do_404($redirect); 
  10.  

Defined (1)

The function is defined in the following location(s).

/bp-core/bp-core-functions.php  
  1. function bp_do_404( $redirect = 'remove_canonical_direct' ) { 
  2. global $wp_query; 
  3.  
  4. /** 
  5. * Fires inside the triggering of a 404. 
  6. * @since 1.5.0 
  7. * @param string $redirect Redirect type used to determine if redirect_canonical 
  8. * function should be be removed. 
  9. */ 
  10. do_action( 'bp_do_404', $redirect ); 
  11.  
  12. $wp_query->set_404(); 
  13. status_header( 404 ); 
  14.  
  15. if ( 'remove_canonical_direct' === $redirect ) { 
  16. remove_action( 'template_redirect', 'redirect_canonical' );