bb_check_ajax_referer

The BuddyPress bb check ajax referer function.

Description

bb_check_ajax_referer( (int) $action = -1, (constant) $query_arg = false, (bool) $die = true ); 

Parameters (3)

0. $action — Optional. (int) => -1
The action.
1. $query_arg — Optional. (constant) => false
The query arg.
2. $die — Optional. (bool) => true
The die.

Usage

  1. if ( !function_exists( 'bb_check_ajax_referer' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-includes/functions.bb-pluggable.php'; 
  3.  
  4. // The action. 
  5. $action = -1; 
  6.  
  7. // The query arg. 
  8. $query_arg = false; 
  9.  
  10. // The die. 
  11. $die = true; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = bb_check_ajax_referer($action, $query_arg, $die); 
  15.  

Defined (1)

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

/bp-forums/bbpress/bb-includes/functions.bb-pluggable.php  
  1. function bb_check_ajax_referer( $action = -1, $query_arg = false, $die = true ) { 
  2. $requests = array(); 
  3. if ( $query_arg ) { 
  4. $requests[] = $query_arg; 
  5. $requests[] = '_ajax_nonce'; 
  6. $requests[] = '_wpnonce'; 
  7.  
  8. $nonce = ''; 
  9. foreach ( $requests as $request ) { 
  10. if ( isset( $_POST[$request] ) && $_POST[$request] ) { 
  11. $nonce = $_POST[$request]; 
  12. break; 
  13. } elseif ( isset( $_GET[$request] ) && $_GET[$request] ) { 
  14. $nonce = $_GET[$request]; 
  15. break; 
  16.  
  17. $result = bb_verify_nonce( $nonce, $action ); 
  18.  
  19. if ( $die && false == $result ) 
  20. die('-1'); 
  21.  
  22. do_action('bb_check_ajax_referer', $action, $result); 
  23. return $result;